Ask a Question related to PHP Development, Design and Development.
-
Dallas Thunder #1
Q: How to get the value of a checkbox of which name without '[]'?
Consider the following form in a HTML file:
....
<input type=checkbox name="box" value=1>
<input type=checkbox name="box" value=2>
<input type=checkbox name="box" value=3>
<input type=checkbox name="box" value=4>
....
Now I'm posting this form into a PHP script. The problem is I can't change
that HTML file. Which means I can't modify the code above into PHP prefered
style:
<input type=checkbox name="box[]" value=1>
<input type=checkbox name="box[]" value=2>
....
So, how can I get the correct values of the checkbox? $_REQUEST['box'] is
not an array and only contains the last value. Thanks!
Dallas Thunder Guest
-
[PHP] Q: How to get the value of a checkbox of which name without '[]'?
> Consider the following form in a HTML file: -
Howto bind CheckBox to the datagrid/ Then update the database field when the checkbox is clicked.
I am trying to update the database field when the checkbox is clicked. I am trying to modified the following solution but.. got stuck on the... -
asp checkbox
Kerri, Do a search for the checkbox list object and how to databind it. It think that's what will work best for you. Sincerely, -- S.... -
<asp:checkbox>
Hi, I have a series of checkboxes on a web page. Based on what the user checks I write a record to a Database Table. I want to associate... -
DIV, CheckBox
Hello, I am populating a DIV with Checkboxes based on rows I get from a Table while dr.read() ..... mydiv.controls.add(etc...) .... other set... -
Greg Beaver #2
Re: Q: How to get the value of a checkbox of which name without '[]'?
You can try using $HTTP_RAW_POST_DATA and parsing it yourself - or grab
the get value directly from $_SERVER['QUERY_STRING']
Regards,
Greg
Dallas Thunder wrote:
> Consider the following form in a HTML file:
>
> ...
> <input type=checkbox name="box" value=1>
> <input type=checkbox name="box" value=2>
> <input type=checkbox name="box" value=3>
> <input type=checkbox name="box" value=4>
> ...
>
> Now I'm posting this form into a PHP script. The problem is I can't change
> that HTML file. Which means I can't modify the code above into PHP prefered
> style:
>
> <input type=checkbox name="box[]" value=1>
> <input type=checkbox name="box[]" value=2>
> ...
>
> So, how can I get the correct values of the checkbox? $_REQUEST['box'] is
> not an array and only contains the last value. Thanks!
>Greg Beaver Guest
-
Frode #3
Re: [PHP] Q: How to get the value of a checkbox of which name without '[]'?
[...snip...]
Which means I can't modify the code above into PHP prefered
style:
<input type=checkbox name="box[]" value=1>
<input type=checkbox name="box[]" value=2>
....
[...snip...]
Why is this the preferred style, and where can I read more about it?
Frode Lillerud, Norway
Frode Guest
-
Cpt John W. Holmes #4
Re: [PHP] Q: How to get the value of a checkbox of which name without '[]'?
----- Original Message -----
From: "Frode" <frode@lillerud.no>
[...snip...]
Which means I can't modify the code above into PHP prefered
style:
<input type=checkbox name="box[]" value=1>
<input type=checkbox name="box[]" value=2>
.....
[...snip...]
I don't know about preferred style or not, but if you want PHP to recognize> Why is this the preferred style, and where can I read more about it?
multiple values from a form or URL, then you must add the [] onto the name
so PHP will put it into an array. Otherwise you end up with
"box=1&box=2&box=3" and when PHP parses that, each overwrites the other, so
you end up with $box == 3 at the end and the other values are lost. I'm sure
it's discussed in the Form Handling section of the manual.
---John Holmes...
Cpt John W. Holmes Guest



Reply With Quote

