Page 1 of 1

validating and processing..

Posted: Fri Feb 10, 2006 1:12 am
by zinc
hi,

i need some help.....
currently, i have a form consisting of some chekboxes....

<td>a <input type="checkbox" name="services" value="a" /></td>

<td>b <input type="checkbox" name="services" value="b" /></td>

<td>c <input type="checkbox" name="services" value="c" /></td>

<td>d <input type="checkbox" name="services" value="d" /></td>

<tdeG <input type="checkbox" name="services" value=G" /></td>

<td>f <input type="checkbox" name="services" value="f" /></td>

i'm doing a validation using javascript...and after the validation i'm suppose to do a $_POST[services]
but for php to display the value the checked checkboxes, the name of the checkboxes must be declared as name="services[]"....with the array box....but if i put the array box, i will not be able to do validation using javascript......

can anybody help??

thx,
zinc

Posted: Fri Feb 10, 2006 1:29 am
by feyd
big hint:

Code: Select all

document.forms['yourFormName'].elements['services[]']

Posted: Fri Feb 10, 2006 2:50 am
by phpScott

Code: Select all

<td>a <input type="checkbox" name="services[]" value="a" id="services" /></td>
javascript

Code: Select all

services = document.getElementById('services');
//do all your fun js stuff here
best of both worlds.