By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,247 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,247 IT Pros & Developers. It's quick & easy.

Pass checkbox value from query results

100+
P: 139
Hi,

This is driving me mad - can someone guide me in the right direction please?

I am outputting the results of a query to a webpage - in this case drawings in a database. The user selects the drawing type and the result pages shows the details.

I have pumped the output into a form and have generated a checkbox for each returned row. I want the user to check the box of drawings they want printed (#form.PrintYN#), so that info can be emailed to the end user. The user can check 1 or more boxes, then hit the submit button to send the drawings image number (#form.myfilepath#) to the query result.

I just cannot get this to happen. I carry over the checkbox value to the results page (so if two boxes are checked I get 'on, on' if I output the value) but I can't get the image number (#form.myfilepath# - the value of which is #filepath#) to carry over as well.

Any ideas how I do this?

Thank in advance
Neil
Feb 24 '11 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Why not set the value of each checkbox to the image number? Then you'll have a list of image numbers.
Feb 25 '11 #2

100+
P: 139
Great idea! I've tried that and it works a treat. Any idea how I can output each record to a seperate line? Looks a bit messy as just a comma'd list.

Thanks for your help
neil
Feb 25 '11 #3

acoder
Expert Mod 15k+
P: 16,027
Use cfloop to loop over the list (see the docs on cfloop).
Feb 28 '11 #4

100+
P: 139
Sorry acoder, I can't seem to find any docs on cfloop on this site?

What I have done is this:
Expand|Select|Wrap|Line Numbers
  1. <cfquery name="getRecords" datasource="swwdrawings">
  2. select *
  3. from    tblDrawingsData
  4. where ID in (#form.mycheck#)
  5. </cfquery>
to get the individual rows, then loop over the output into a table so the user can add paper size, no of copies etc. I now want to insert this back into a new table in the database to be retrieved later.

My question is this: how do I output these form fields as individual rows to the table? CF just dumps all the info in one record. I'm sure the answer is to do with cfloop, but im guessing I can't loop over form fields, just info extracted from the database.

Thanks for your helps so far!
Mar 2 '11 #5

acoder
Expert Mod 15k+
P: 16,027
I meant the official Adobe docs.

Anyway, I'm not sure which table you refer to in your question. By table, do you mean an HTML table or a table in a database?

In Coldfusion, any string which contains delimiters (usually a comma) can be treated as a list. So if #form.mycheck# is 1,2,3, you can use cfloop:
Expand|Select|Wrap|Line Numbers
  1. <cfloop index="listitem" list="#form.mycheck#"> 
  2.     <cfoutput>#listitem#</cfoutput><br>
  3. </cfloop>
Mar 4 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.