Solved

Storing Users Selections

Posted on 2003-11-28
6
152 Views
Last Modified: 2013-12-24
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?

0
Comment
Question by:zakirdavis
6 Comments
 

Author Comment

by:zakirdavis
ID: 9839356
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....
0
 
LVL 9

Accepted Solution

by:
svenkarlsen earned 500 total points
ID: 9839376
Hi zakirdavis,
Make a separate selection dataset with fields:

UserID, RecordID

When user enters database, clear all records for that user in the selection dataset

use a query as source for your for your form, linking on the RecordID and filtering on UserID

for the checkbox, make the code add a record to the selection dataset with UserID and RecordID when checked, and attempt to delete same record when unchecked

Kind regards,
Sven
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9841457
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 !!!
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 17

Expert Comment

by:Tacobell777
ID: 9841494
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...
0
 
LVL 4

Expert Comment

by:procept
ID: 9841740
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
0
 

Author Comment

by:zakirdavis
ID: 9841760
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.
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now