By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Storing checkbox selections between record paging

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.