Wednesday, 5 March 2008

Prototype.js get checked elements

To get the checked elements from a group of checkboxes you can use the select and css3 selectors shortcut:

var checked_el=surrounding_el.select('input:checked').each(function(checked_el) {
//do something with only the selected elements
alert("checked_element: "+checked_element.id);
});

/*
checked_el is a array holding the found elements
surrounding_el is a fieldset or div that encloses the checked boxes
select('input:checked') - select all with a CSS3 seletor type
of checked (http://www.w3.org/TR/css3-selectors/)
.each(function(checked_el) - loops on all the ones that are found
*/

Wednesday, 20 February 2008

google maps marker z index

Google have now prevented access to marker.setZIndex() (which was undocumented method anyway) A work around to get your marker to the top is:

function add_marker(){
var marker = new GMarker(point,{zIndexProcess:importanceOrder});
marker.importance = 2; //higher importance = higher marker z index
the_map.addOverlay(marker);
}

function importanceOrder (marker,b) {
return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000;
}

which moves the marker higher up - note you'll need to do this after you've added all the markers to the map. Otherwise the next z-index will continue after the last one you added (effectively cancelling out your increase in z-index)

Thursday, 24 January 2008

Coldfusion query column to array

The normal method of converting Coldfusion query column to array is to use a valuelist and list to array:

the_array=listtoarray("#valueList(the_query.the_column)#")

But this strips out any cells with empty strings in. To get around this use:

the_array=duplicate(the_query[column_name]);
ArrayPrepend(the_array,the_query[column_name][1]);

why the ArrayPrepend() call afterwards? Because CF arrays start at 1 and Java (the underlying language) starts at 0, so the duplicate function misses off the first row of the column.

nice.