473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem with checkbox

I have got a problem with checkboxes array and the form.
I have the results from table (MySQL) and checkbox (form) near the results.
I use:
echo "<input type=checkbox name=box[] value=".$['lp'].">";
for checkbox i.e. I create array of checkbox.
How can I remember the state of checkboxes in array and pass it by GET?
I know how to do it with a single checkbox already selected inside the code:
$next = " <a href=\"$self?page=$page&amp;$box=13\">"."&rsaquo;" ."</a>
but I don't know how to check its state and remember.
I use paging of the results with GET and canot use POST because it is reserved for passing data to another form.
Any help is welcome :)
May 13 '07 #1
5 2372
What????

You need to explain this clearly.

Where does the array come from? Does it have your mysql results in it? Are you creating a page with checkboxes on it from the mysql results? Or have you got results from mysql and more results from some checkboxes? Are you trying to take a user's checkbox selections and pass them back to another page?
?????????????????????????????????????????????????? ?????????????????
May 13 '07 #2
What????
Are you trying to take a user's checkbox selections and pass them back to another page?
?????????????????????????????????????????????????? ?????????????????
Thanks for mail, Yes exactly I try to take users selection and pass it to previous or next page with a GET.

I have got a table from database (sql):
1. Letter 1 - Editor
2. Letter 2 - Aunt
3. Letter 3 - Johny
The number of records can be large so I use pagging with GET.
It works fine.
I added form and checkbox near each record which looks like:
1. Letter 1 - Editor [] 6
2. Letter 2 - Aunt [] 7
3. Letter 3 - Johny [] 9
The value of checkbox is the record numer in database on the right side.
I checked for example 1 and 3 record. When I am back on the same page I would like to see previously checked (selected) records, but all checkboxes are unchecked :(.
I can not use POST (I use it to pass data for another form and it works fine).
I know how to remember a single checkbox insied php script I put $box=2 and it works. But I have no idea how to do an array passing by GET.
I know I should set box[] insted of box in form input. I have array of checkboxes.
I don't know how to pass an array by GET.
May 13 '07 #3
Atli
5,058 Expert 4TB
Hi.

You will have to name all fields in the array the same name, followed by [].
When posted, this data will exist as an array inside the $_REQUEST array, each field containing the value parameter of the input tag.

For example, if you have 3 checkboxes named box[], and set the value of each from 0 to 2 and only check the first and the third.
You will be able to access the data from the other side by doing something like this:
[PHP]
$_REQUEST['box'][0]; // The first checked box, value = 0
$_REQUEST['box'][1]; // The second checked box, value = 2
[/PHP]

It only passes on the boxes that you checked, so the array it passes will only contain two fields, the first and the third.

If this is unclear, you can view the entire contents of the array by doing this:
[PHP]
print_r($_REQUEST['box']);
[/PHP]
May 13 '07 #4
Many thanks, I added a line:
echo "<input type=checkbox name=box[] value=".$d['id'].">";
what returns a checkbox array (of course a single one for each record).
$_REQUEST doesn't work.
print_r is empty.
echo '<pre>';
var_export( $_REQUEST );
echo '</pre>';
returns nothing.
It does require POST? I can use only GET.
Help me pleeeez...
May 13 '07 #5
Atli
5,058 Expert 4TB
Many thanks, I added a line:
echo "<input type=checkbox name=box[] value=".$d['id'].">";
what returns a checkbox array (of course a single one for each record).
$_REQUEST doesn't work.
print_r is empty.
echo '<pre>';
var_export( $_REQUEST );
echo '</pre>';
returns nothing.
It does require POST? I can use only GET.
Help me pleeeez...
Can you give us more of your code? It is hard to debug a code you can't see :)

First thing that jumps at me there, XHTML requires you to put variable values inside quote marks, so you should try writing your HTML like this.
[HTML]
<input type="checkbox" name="box[]" value="0" />
[/HTML]

Also, why can't you use post?
May 13 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Claire | last post by:
Hello, I am having a problem in my struts application with the checkboxes in my form. I have an array of checkboxes, some of which may be already selected when the form loads. My problem is when...
3
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
17
by: Phil McKraken | last post by:
I am having a problem putting together a shopping cart with the below script. Everything displays fine, adds totals fine, and works perfect EXCEPT if you choose the 9.95 item #5 BY ITSELF the total...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
1
by: spolsky | last post by:
try the the following code with Opera 9.01 (Windows). when clicked slightly faster than normal clicking, the toggler checkbox and other checkboxes displays differently although event method works...
9
by: morellik | last post by:
Dear all, I have a program that creates dinamically a web page. In the page I have the following function to check how many checkbox are checked. function tarInfo(info) { var i=0; var c=0;...
1
by: Trev | last post by:
Hi, I'm hoping that someone in this group can shed some light on an issue I'm having with a Formview. I have a Web User Control (.ascx) with a Formview. The Formview contains 2 Multiviews,...
2
by: swethak | last post by:
Hi, i am getting the problem when i used the onclick event in option tag.It is working fine in mozilla .But it is not working IE. Here is my code <script>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.