Fixed and simplified setSelectOptions

Deselecting was broken
This commit is contained in:
Piotr Przybylski
2011-04-27 20:54:57 +02:00
parent 1cc51458b5
commit 7049046a55

View File

@@ -705,19 +705,13 @@ function setCheckboxes( container_id, state ) {
* *
* @param string the form name * @param string the form name
* @param string the element name * @param string the element name
* @param boolean whether to check or to uncheck the element * @param boolean whether to check or to uncheck options
* *
* @return boolean always true * @return boolean always true
*/ */
function setSelectOptions(the_form, the_select, do_check) function setSelectOptions(the_form, the_select, do_check)
{ {
$("form[name='"+ the_form +"'] select[name='"+the_select+"']").find("option").attr('selected', do_check);
if( do_check ) {
$("form[name='"+ the_form +"']").find("select[name='"+the_select+"']").find("option").attr('selected', 'selected');
}
else {
$("form[name='"+ the_form +"']").find("select[name="+the_select+"]").find("option").removeAttr('selected');
}
return true; return true;
} // end of the 'setSelectOptions()' function } // end of the 'setSelectOptions()' function