PDA

View Full Version : problem with multiple checkboxes with same name but dif...


Aoshi
04-02-2001, 05:44 AM
I have several checkboxes that I want to have all the same name, but different values.
so like
<input type=&quot;checkbox&quot; name=&quot;myname&quot; value=&quot;yup&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname&quot; value=&quot;nope&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname&quot; value=&quot;happy&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname&quot; value=&quot;yappy&quot;>

assume, the user checks all 4 of the above checkboxes.

now....I'm assuming that the php page that these values are sent to, will automatically have the variable $myname available and ready to go with all four values stored in it somehow.
my question is....does this really work in php?[nbsp][nbsp]and if so...how are the different values stored in $myname?...as an array?
I tried something similar to the above...and when i printed out what $myname was equal to...it came out to be just &quot;yappy&quot;.[nbsp][nbsp]What happened to all the first three values?

Thanks in advance!
<!-- NO_AUTO_LINK -->

Arthur
04-02-2001, 06:19 AM
Replace all of the instances of name=&quot;myname&quot; with name=&quot;myname[]&quot;.
<input type=&quot;checkbox&quot; name=&quot;myname[]&quot; value=&quot;yup&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname[]&quot; value=&quot;nope&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname[]&quot; value=&quot;happy&quot;>
<input type=&quot;checkbox&quot; name=&quot;myname[]&quot; value=&quot;yappy&quot;>

That way you'll end up with the array $myname which contains all the values the user chose.

HTH,
Arthur

Aoshi
04-02-2001, 03:57 PM
thanks arthur.
that works!
such a simple thing....i sorta thought it would have made $myname automatically into an array.
but now I know!
thanks.