I am using the jQuery 1.6.2.
I am dynamically populating a select box using ColdFusion and jQuery.
When the options are returned and stuffed inside the select box, I’d jQuery to figure out how many options there are and adjust the size attr as needed.
// load the options into the select box
$("#Select").load("GlobalAdmin/ArtistUnassociatedAlbums.cfm?" + QString);
// test the number of options
var NumOfOptions = $();
var BoxSize = 0;
// do a calculation
if (NumOfOptions > 10) {
BoxSize = 10;
} else {
BoxSize = NumOfOptions ;
}
// adjust the select box size
$("#AlbumsSelect").attr("size", BoxSize );
How do I efficiently get at the number of options returned?
Yea just use the
lengthproperty…