473,378 Members | 1,119 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,378 software developers and data experts.

Storing checkbox selections between record paging

Reposted (not sure if got sent)
I have results being displayed each with its own checkbox name
"selected[]" and value "id".

When someone checks a checkbox, and then continues to page through the
data (mysql select), I want that checkbox to be remembered. Basically
I want the user to have multiple selections of checkboxes when paging
through data (recordset), then they click a "continue" button, it
takes all those values which are checked (over all the pages) and does
its thing (insert into a database).

One way I thought of is a JavaScript onClick each time a checkbox is
ticked, it adds it to an array, then uncheck would delete it from that
array. I'm just not sure how I'd get that javascript array through to
PHP. It sounds overly complicated.

Another way is running a query every time a page is loaded. So on the
pageing buttons, I force the form to submit each time, writing that
pages data into a PHP $_SESSION array. But I dont know how to
differentiate when the page buttons are submitting the form or when
the button is submitting the form, and I figured there must be an
easier way.

Kind regards
Jul 17 '05 #1
1 4651
RelaxoRy wrote:
Reposted (not sure if got sent)
I have results being displayed each with its own checkbox name
"selected[]" and value "id".

When someone checks a checkbox, and then continues to page through the
data (mysql select), I want that checkbox to be remembered. Basically
I want the user to have multiple selections of checkboxes when paging
through data (recordset), then they click a "continue" button, it
takes all those values which are checked (over all the pages) and does
its thing (insert into a database).

One way I thought of is a JavaScript onClick each time a checkbox is
ticked, it adds it to an array, then uncheck would delete it from that
array. I'm just not sure how I'd get that javascript array through to
PHP. It sounds overly complicated.
http://mickweb.com/javascript/forms/...kboxArray.html

<script type="text/JavaScript">
onload= function(){
var d=document.forms[0],w=d.length;
while(w--){
if(d[w].type=="checkbox"){
d[w].onclick=function(){
var f=this.form,x=f.length,temp=[];
while(x--){
if(f[x].type=="checkbox" && f[x].checked){
temp.push(f[x].value);
}
}
this.form.hiddenFieldName.value=temp.join(",");
}
}
}
}
</script>

This will be available to your parsing document as comma delimited string.

Mick
Another way is running a query every time a page is loaded. So on the
pageing buttons, I force the form to submit each time, writing that
pages data into a PHP $_SESSION array. But I dont know how to
differentiate when the page buttons are submitting the form or when
the button is submitting the form, and I figured there must be an
easier way.

Kind regards

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RelaxoRy | last post by:
I have results being displayed each with its own checkbox name "selected" and value "id". When someone checks a checkbox, and then continues to page through the data (mysql select), I want that...
4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
14
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
1
by: iforsyth | last post by:
Have a paging datagrid with a checkbox control in column(0). ViewState is enabled. I check the checkbox in first row of the grid on a page and then the program hits this event: Private Sub...
2
by: Mark | last post by:
I am attempting to build a repeating list using a repeater control. I want to add a checkbox to each item (line) and 'Select All' and 'Clear All' buttons. I have figured out how to do this...
0
by: Scott P. | last post by:
I'm creating an app using ASP .NET (my second app so bear with me here) that basically builds a PDF file based on a bunch of user selections. I have a page which displays a series of checkboxs...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
by: dixonjm | last post by:
I have quite a complicated problem with the above. I will do my best to explain, although I have a word doc (too large to attach here 149KB) with the problem explained full with screen shots if any...
11
by: =?Utf-8?B?UGFyYWcgR2Fpa3dhZA==?= | last post by:
Hi All, I have a large recordset to be displayed on a ASP 3.0 page. I am using recordset paging for this. For the next and previous link i am passing href as <a href=<Page URl>?page=<%=...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.