How about something like this?
jQuery.fn.selectOption = function(v) {
return jQuery.each(function(){
for ( var i=0; i < this.options.length; i++ )
if ( this.options[i].value == v ) {
this.selectedIndex = i;
return;
}
};
};
$("#GlobalSelectGoButton").click(function(){
$("select").
not("#GlobalSelect").
selectOption($("#GlobalSelect").value());
};
I don't know what it would do with a multiple-select. If there isn't a
matching value you might want to think about what it should do there; I just
leave the current selection alone. Also, I _think_ that the currently
selected option's value should be available through .value() but haven't
tried it.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Andy Matthews
Sent: Tuesday, October 24, 2006 12:29 PM
To: [jQuery]
Subject: [jQuery] Updating multiple select fields at once
I've got a page which allows a user to set profiles for hours of the day.
There are a LOT of dropdowns on this page and I've had some users which say
they want to set all the dropdowns to a specific value. Setting them all
manually would take a few minutes of time. So the users want to know if they
can set all to a certain value at one time.
I'm already using jQuery on this site for various things. I'm wondering if I
can add one more dropdown which might read "Set all values to: [select box]
[go]".
The only select boxes on this page are in the app so I suppose I could get
all select boxes and set the option to the value of the "All" dropdown. I'm
going to try to do it myself, but does anyone have an idea how to accomplish
this?
<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/