
6 Sep
2011
6 Sep
'11
10:06 a.m.
The normal way of reading a form value is: var city= $("[name='city']").val(); //using the element's name or var city= $("#city").val(); //using the element's ID Question: What if you had several checkboxes e.g. <input type='checkbox' name='cities[]' value='Kisumu' /> <input type='checkbox' name='cities[]' value='Mombasa' /> <input type='checkbox' name='cities[]' value='Nairobi' /> And you want to find out which one's the user clicked on, assuming that the user can choose more than one. var city= $("[name='cities[]']").val(); //is not working