1

I'm a bit rusty in PHP, I'm curently doing an PHP assignment where a user can select and save listed images/data/values into their own collection. I have inputted all the data and printed it out in a repeat region with recordset paging.

I'm confused about how I am supposed to save a checked checkbox temporary before submission as there a more then 1 page as I'm using recordset paging to output the options.(Meaning: i have selected 2 values in the first page then i click next page to select balance values and finally submit my selection)

TIA

I have read an article on storing in session , that is the solution I guess, but I wonder how I'm supposed to send the value to the session when chaging the page (recordset paging generated by Dreamweaver)

thomaux
  • 19,133
  • 10
  • 76
  • 103
Shar678
  • 35
  • 1
  • 8

3 Answers3

2

To clarify the previous answers, you will most likely want to create a new $_SESSION variable for each check-box and associate a boolean with it.

Will
  • 733
  • 8
  • 23
  • Thanks for the quick reply. Yes its a great idea but i'm wondering how am i suppose to parse the value? POST ? but i not submitting the form – Shar678 Apr 18 '12 at 18:13
  • Is there a reason you can't post the form and use those post variables in addition to the next one to create a completed form? Because I believe that would work. – Will Apr 18 '12 at 18:22
  • Sry My question may sound silly,(rusty programmer), i haven't mention this to you , I have generated a recordset paging (generated by dreamweaver) where 50 img first page and if more next page will be available. I have checked the code it is not submitting the form when clicked and when i go back page the checked value is no more there. I have read article on storing in session, i guess that is the solution but i wonder how i'm suppose to send the value to the session when next page is clicked. – Shar678 Apr 18 '12 at 18:29
  • Is there any way to submit when next page link is clicked.I have tried the onclick on the link but it not working – Shar678 Apr 18 '12 at 18:31
  • I do not know anything about recordset paging (or Dreamweaver for that matter, I just use it because I like the way it formats my text) but it sounds like Javascript could be the answer and just save them as cookies(or Session variables ideally) until you're ready to submit. You could create a Javascript function that fires from the onClick for next page that loops through the page to find what is checked and then stores it in the session as true or false. – Will Apr 18 '12 at 18:32
  • yes , maybe that could be the solution. is there and tutorial / site that you would like to suggest for me to have a look at ? since i dont wan to disturb the generated paging, hope javascript can help me save the selected values temporary onclick and then use the value when submit is clicked. – Shar678 Apr 18 '12 at 18:37
  • For JS general, w3schools. For this exact thing? My advice is to make a function that loops through the document checking the value of the check boxes. You'll have to dynamically name the checkboxes (Checkbox1, checkbox2 ect.) and from there, you can loop through them and register each one as a session variable. It gets kinda strange, just remember, PHP can be in your javascript and vice versa, it's just a bit convoluted at times. If it helps, get the Javascript loop working before you implement the PHP aspect. – Will Apr 18 '12 at 18:49
  • Hi Moby, I'm stuck again.i know how to call the function and pass the checkbox value but i realize this wont work ,and wat you said loop is more logic as when he uncheck still it rechecks which is better but how? i can create loop but how to do the checking ? i really not sure. how to loop and check – Shar678 Apr 19 '12 at 16:13
1

You can store the result of a form post in PHP's $_SESSION variable. Read this post for more information: Storing Form Data as a Session Variable

Also, there has to a tutorial or something in Google Land.


If you need to save the form results without submitting the form, try a JavaScript/AJAX approach. The idea is that you actually do submit the form, but in a behind-the-scenes kind of way (that is, the user never notices it). Essentially, you're going to want to build a "autosave" functionality. Look at these two posts:

They probably won't fit your needs exactly, but they should give you a good idea of what you should do.

Note: both of these posts use a timer to trigger their autosave functionality. I would suggest tweaking the trigger to detect any changes in your form instead.

Community
  • 1
  • 1
Ayman Safadi
  • 11,502
  • 1
  • 27
  • 41
  • Hi Ayman Safadi, Thanks for your quick reply. Yes i have read the articles and found this solution but the problem is how am i suppose to send the value (POST) when i'm not submitting. I'm using recordset paging generated by Dreamweaver. – Shar678 Apr 18 '12 at 18:11
  • thanks alot really appreciate you help . Will have a look at your links. I think i have found a solution to it also. – Shar678 Apr 19 '12 at 09:39
0

Store them in _SESSION and process when needed.

PoX
  • 1,229
  • 19
  • 32
  • Tq very much for the suggestion yes i read few articles online and found this solution to but i wondering how i'm suppose to send the value when i click the next page button (recordset paging generated by dreamweaver) – Shar678 Apr 18 '12 at 18:15
  • you need to bind a service call to UI control if you are doing it from dreamweaver. – PoX Apr 18 '12 at 18:35