Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to get info from multiple pages into one. Help!!

Status
Not open for further replies.

fiuPikeOY

Programmer
Jun 14, 2004
143
US
Hello,

I need to summarize in one page all the statements that a user has selected (via checkbox) across multiple pages (via Next, Next, Next). The final page will only have the ones he/she checked off. These statements are pulled from a database, and some may be added or deleted over time.

How can I get all those checked statements in the final page? Session variables? They would need to be created on the spot.

Can this work?

thanks in advance
 
Yes, session variables would do it since they will persist across the pages. You will need to loop through the checkboxes for each page to store the current values as you start the next page.

Remember that checkbox values don't exist for CF unless they have been checked. So when setting the session values you will need to provide a default value for each checkbox so that unchecked boxes don't generate an error (variable not defined). You might want to store the values in an array or structure and then put this into a session variable as you move along.

Then on the last page you can loop through the array or structure to get all the values. Be sure to delete the session variable(s) when you are done so that you won't have old data persisting past the point where you need it.
 
If you're using checkboxes, then you're using forms. Why not just pass the value from each form to the next one in hidden fields?

(Thanks to webmigit for this snippit of code.)
Code:
<cfoutput>
  <cfloop list="#form.fieldnames#" index="f">
    <input type="hidden" value="#jsstringformat(FORM[f])#" name="#f#">
  </cfloop>
</cfoutput>
This will loop through all of the form fields passed from the previous form and put them into hidden form fields in the current form. I try not to use Session variables for stuff like this becuase even after you've submitted the form, the variables still exist and can cause problems later on down the road (like trying to fill out the form again). Anyway, that just my personal preference.



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
thank you all for you input I will try that shortly.

right now I'm having a small problem....

this is my code to loop throught the database and populate the checkboxes

<cfoutput query="rs_tkStepsNeeded">
<input name="checkbox" type="checkbox" id="stepID" value="#rs_tkStepsNeeded.tkStepID#" />
#rs_tkStepsNeeded.tkStepsNeeded#
<br />
</cfoutput>

if you notice the value = stepID which is the identifier in the database. What would be the code to display in another page the content of a column called "stepsToTake" given all the stepsNeeded that were clicked

I tried this but it only works if I only click one.

<cfoutput query="rs_stepsToTake">#rs_stepsToTake.stepsToTake#</cfoutput>


Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top