PDA

View Full Version : checkbox ticking



ACJavascript
Feb 27th, 2006, 03:47 PM
Hey all,

I have a delema. I created my checkbox fields using the same name (an array) so I can easily pass the information to my php script.

For example:

<input type="checkbox" name="myfield[]" value="1">1
<input type="checkbox" name="myfield[]" value="2">2
<input type="checkbox" name="myfield[]" value="3">3

Now this works great when I pass it to php, I can just do a loop through the fields.

Now, I want the user to be able to click the "1","2", or "3" and have the checkbox tick.

I could easily do this if each checkbox had a name, but these have the same names.

How can I work around this??

Any suggestions?

Nischumacher
Feb 27th, 2006, 03:53 PM
TRY THiS...

<input type="checkbox" name="myfield[]" id="cb1" value="1"><label for="cb1">1</label>
<input type="checkbox" name="myfield[]" id="cb2" value="2"><label for="cb2">1</label>
<input type="checkbox" name="myfield[]" id="cb3" value="3"><label for="cb3">1</label>

ACJavascript
Feb 27th, 2006, 04:06 PM
that worked wonders!!!

Thanks a million!