Re: Array variable in Javascript & PHP
| From: | Danny Shepherd | Date: | Mon, 29 Jul 2002 15:29:46 +0000 |
| Subject: | Re: Array variable in Javascript & PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110189@lists.php.net to get a copy of this message | ||
Try using:
<input type="checkbox" id="list1" name="list1[]"
value="Education"
onclick="addList()"> Education
<input type="checkbox" id="list1" name="list1[]"
value="Profession"
onclick="addList()"> Profession
That's what I used when doing something pretty similar to you.
HTH
Danny.
----- Original Message -----
From: "Sheni R. Meledath" <sheni@cyber-gear.com>
To: "PHP Masters" <php-general@lists.php.net>
Sent: Monday, July 29, 2002 4:11 PM
Subject: [PHP] Array variable in Javascript & PHP
> Hello:
>
> In a form I am using a series of check boxes for a number of lists. Some
> calculations has to be done on the client side using Javascript depending
> upon the check box values. For this I am using a single variable name
> (array) for the check boxes in a list and another for the next list and so
> on. The format I have used is
> <input type="checkbox" name="list1" value="Education"
> onclick="addList()">
> Education
> <input type="checkbox" name="list1" value="Profession"
onclick="addList()">
> Profession
>
> I can access these variables from Javascript as list1[0] & list1[1].
> (document.form.list1['0'].checked & document.form.list1['1'].checked
>
> But when this form is submitted to the PHP script I am getting only the
> last value. list1 = 'Profession'. I am not getting an array of values.
> <?
> for ($i=0; $i<count($list1); $i++)
> {
> $listall .= '$list1[$i],';
> }
> ?>