Forum Moderators: open

Message Too Old, No Replies

Multiple Selects

         

silentstriker

6:44 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



I have a multiple select of N number of items.

If the user selects ALL possible items in the select box (say there are 20, then he selects 20, if there are 100, he selects 100), then I need to to make a checkbox checked. If he selects less than all the possible items (99/100, 1/100, etc..), then I need to uncheck a checkbox.

How is this possible in javascript? The number of items in the multiple select box change.

silentstriker

7:14 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Figured it out myself, simpler than I thought :)

function pick()
{
var allSelected=true;
var totVars=document.forms[0].committee.length;

for(x=0;x<totVars; x++) {
if (!(document.forms[0].committee[x].selected))
allSelected=false;
}

if(allSelected) {
document.forms[0].committee_null.checked=true;
} else {
document.forms[0].committee_null.checked=false;
}
}
</script>