Search Results

Search found 1 results on 1 pages for 'sadpcd'.

Page 1/1 | 1 

  • listbox select count not work dont work

    - by sadpcd
    I recently trying to make a form with multiple select box. When someone select the options the number of selected options will be display on another text. I'm a beginner in JavaScript. The function is called, but it doesn't count the number of the selected options. <select name="element_17_1[ ]" size="7" multiple="multiple" class="element select medium" id="element_17_1[ ]" onfocus="selectCount(this.form);" onClick="selectCount(this.form);" > <option value="Opt1">Opt1</option> <option value="Opt2">Opt2</option> <option value="Opt3">Opt3</option> <option value="Opt4">Opt4</option> <option value="Opt5">Opt5</option> <option value="Opt6">Opt6</option> <option value="Opt7">Opt7</option> </select> and this is the function I tried in the <head> function selectCount(f) { var selObj = myForm.elements['element_17_1[]']; var totalChecked = 0; for (i = 0; i < selObj.options.length; i++) { if (selObj.options[i].selected) { totalChecked++; } } f.element_9.value = totalChecked; }

    Read the article

1