Passing HTML input to php
Moderator: General Moderators
-
RicInACloak
- Forum Newbie
- Posts: 2
- Joined: Tue Jun 03, 2003 9:20 am
Passing HTML input to php
I have an HTML page containing multiple check boxes. It also contains a javascript to toggle the checks off and on, or to select all. The javascript requires that all the checkboxes have the same name attribute, although i have given them different id's. this all works fine, but when i click through to a php page, I can only see the last checkbox, in javascript they are treated as an array of controls, and thats roughly what i expected to get in php. $_REQUEST simply doesnt contain what i need, is the re a solution in php (definitely the preferred option), or do i need a different solution in javascript.
are you using post or get?
i think that javascript arrays do not get converted automagically. I seem to remember a user note on the php manual pages.
searching for "javascript array" on the whole php site seems to yield results:
http://www.google.com/search?q=javascri ... p.net&l=en
i think that javascript arrays do not get converted automagically. I seem to remember a user note on the php manual pages.
searching for "javascript array" on the whole php site seems to yield results:
http://www.google.com/search?q=javascri ... p.net&l=en
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Basically PHP uses the name attribute as it's reference so if they're all the same, (e.g. all have name="checkbox") then you will only ever get the last checked value as each will overwrite the previous one. You could use an array e.g.
which will give you an array of values to use in PHP, don't know how this impacts your JavaScript though.
Mac
Code: Select all
<input type="checkbox" name="checkedї]" value="1" />
<input type="checkbox" name="checkedї]" value="2" />Mac
I found that I had to explicitly assign the array indexes or otherwise when the form was posted my array would only contain the checkboxes that were on... that made for some interesting bugs when we had multiple arrays in sync with each other.
so instead of:
I had to use:
anyone else run into this? maybe it was just with the older versions of php, haven't tested it in a while.
so instead of:
Code: Select all
<input type="checkbox" name="checkedї]" value="1" />
<input type="checkbox" name="checkedї]" value="2" />Code: Select all
<input type="checkbox" name="checkedї0]" value="1" />
<input type="checkbox" name="checkedї1]" value="2" />-
RicInACloak
- Forum Newbie
- Posts: 2
- Joined: Tue Jun 03, 2003 9:20 am