javascript - Limit number of boxes checked when arrays are involved -


i'm pretty amateurish when comes javascript stuff, apologize if question comes off bit dumb.

i'm trying code involves forms limit on how many checkboxes can selected. method i've come across has worked best purposes far 1 detailed here:

http://www.javascriptkit.com/script/script2/checkboxlimit.shtml

it works part run issue when checkboxes need output array. example, if write input line as:

<input type="checkbox" name="choice[]" value="one" /> one<br /> <input type="checkbox" name="choice[]" value="two" /> two<br /> <input type="checkbox" name="choice[]" value="three" /> three<br /> 

i've tried quite few things can't figure out how change code works brackets in input's name field.

using script above, can change using .elements group of elements , applying same custom function:

<script type="text/javascript">  // syntax: checkboxlimit(checkbox_reference, limit)  var world_form = document.forms.choices; // form var my_checkboxes = world_form.elements['choice[]']; // check boxes checkboxlimit(my_checkboxes, 2);  </script> 

fiddle


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -