Storing checkbox selections between record paging

This is a discussion on Storing checkbox selections between record paging within the PHP Language forums, part of the PHP Programming Forums category; Reposted (not sure if got sent) I have results being displayed each with its own checkbox name "selected[]" ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-08-2005
RelaxoRy
 
Posts: n/a
Default 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
Reply With Quote
  #2 (permalink)  
Old 01-08-2005
Mick White
 
Posts: n/a
Default Re: Storing checkbox selections between record paging

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:53 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0