Link to home
Start Free TrialLog in
Avatar of zakirdavis
zakirdavis

asked on

Storing Users Selections

I developed a form that shows my database contents, with a check box next to each row. I want the user to be able to select multiple rows (via checkbox), submit the selections; the submissions will be added to a cart and the user can continue browsing to other categories and add more rows from other pages to the cart. The user will then view his/her cart and finally submit their selections via cfmail form to an administrator. Any suggestions?

Avatar of zakirdavis
zakirdavis

ASKER

BTW, my checkboxes are dynamically named by the primary key of each row. I know this will help in identifying the properties. Any tips or recommendations would be helpful. I am not sure how to design this. Using structures, arrays, store information in another table that expires over time....
ASKER CERTIFIED SOLUTION
Avatar of svenkarlsen
svenkarlsen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess i had commented your previous comments on the same question u have asked 3rice in last week.

pls stick to one thread - rather than opening multiple ones with the same question in it !!!
You could store the user selections in the session scope once the form is submitted, for example if the session did not yet exist you could do something like
<cfset session.cart = duplicate(form)>
This would copy all values submitted into the session scope, if the user would submit another form (the session would exist already at this stage) you would append the values to the existing session
<cfset structAppend(session.cart, form)> (I believe this is the right syntax)
you would need to be careful because an append can overwrite your existing values if they are named the same.

This will get you going anyway...
Hi,

a table can not automatically expire over time. If you use a session var, you need to check for it's existance every time you access it (because it won't exist if it's expired). You can set a timestamp to manually expire tables, vars, etc.

BTW. name your checkboxes all the same! Give them unique values, not individual names! It's much easier to handle selected values this way:

<!--- if the user selected at least one checkbox --->
<cfif isDefiend("form.myCheckBox")>
   <!--- loop over selected items --->
   <cfloop list="#form.myCheckBox#" index="idx">
      <!--- do whatever you need to do with the item --->
   </cfloop>
</cfif>

HTH,

Chris
thanks for the input. i am tired and will accept an answer tomorrow. as for the multiple posts, it is a three part question, so i figured to ask each part of it in different questions. I didnt want people to think it was too much to answer in one question. thanks for the input.