•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 423,555 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,783 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums
Views: 1032 | Replies: 1
![]() |
•
•
Join Date: Feb 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Ok so I'm making a survey for a website and I have a series of questions where the user can rate it from a list of choices and I have these questions in a table in access and the rating options in a table. I want to have the questions display with the options in a dropdown box next to each question, I can't seem to get this to work. Here is my code:
coldfusion Syntax (Toggle Plain Text)
<!--- Get ratings ---> <cfquery datasource="PFB" name="RatingsQ"> SELECT * FROM Ratings, Questions ORDER BY RatingID, QuestionID </cfquery> <!--- Get genders ---> <cfquery datasource="PFB" name="Gender"> SELECT * FROM Gender ORDER BY ID </cfquery> <!--- Get states ---> <cfquery datasource="PFB" name="State"> SELECT * FROM State ORDER BY StateID </cfquery> <!--- Get questions2 ---> <cfquery datasource="PFB" name="Questions2"> SELECT * FROM Questions2 ORDER BY Question_ID </cfquery> <!----get ages-----> <cfquery datasource="PFB" name="Age"> SELECT ID, Age FROM Age ORDER BY ID </cfquery> <html> <body> <cfform action="insertnewreview.cfm"> <table> <tr> <td>Age:</td> <td> <select name="AgeID"> <cfoutput query="Age"> <option value="#ID#">#Age#</option></cfoutput> </select> </td> </tr> <tr> <td> Gender: </td> <td> <select name="Gender"> <cfoutput query="Gender"> <option value="#Gender#">#Gender#</option></cfoutput> </select> </td> </tr> <tr> <td> State: </td> <td> <select name="State"> <cfoutput query="State"> <option value="#State#">#State#</option></cfoutput> </select> </td> </tr> <tr> <td><cfoutput query="RatingsQ"><br><br>#Question#</td><td><select name="RatingID"><option value="#RatingID#">#Rating#</option> </select></cfoutput></td></tr> <tr> <td><cfoutput query="Questions2">#Q#:</cfoutput></td> <td>Answer: <textarea></textarea></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Insert"></td> </tr> </table> </cfform> </body> </html>
Last edited by peter_budo : Apr 7th, 2008 at 7:02 pm. Reason: Keep It Organized - please use [code] tags
The group attribute of cfquery is one of the most unknown and under-appreciated pieces of the entire language. It's so incredibly simple to use it's a wonder more people aren't told about it.
I modified your output to use grouping and it should make your life a little easier (programming life at least, I'm not a messiah
)...
Take a look at lines 67-83
I also changed lines 85-94 a little to make the output of the Question2 section a little cleaner.
I modified your output to use grouping and it should make your life a little easier (programming life at least, I'm not a messiah
)...Take a look at lines 67-83
ColdFusion Syntax (Toggle Plain Text)
<!--- Get ratings ---> <cfquery datasource="PFB" name="RatingsQ"> SELECT * FROM Ratings, Questions ORDER BY RatingID, QuestionID </cfquery> <!--- Get genders ---> <cfquery datasource="PFB" name="Gender"> SELECT * FROM Gender ORDER BY ID </cfquery> <!--- Get states ---> <cfquery datasource="PFB" name="State"> SELECT * FROM State ORDER BY StateID </cfquery> <!--- Get questions2 ---> <cfquery datasource="PFB" name="Questions2"> SELECT * FROM Questions2 ORDER BY Question_ID </cfquery> <!----get ages-----> <cfquery datasource="PFB" name="Age"> SELECT ID, Age FROM Age ORDER BY ID </cfquery> <html> <body> <cfform action="insertnewreview.cfm"> <table> <tr> <td>Age:</td> <td> <select name="AgeID"> <cfoutput query="Age"> <option value="#ID#">#Age#</option> </cfoutput> </select> </td> </tr> <tr> <td> Gender: </td> <td> <select name="Gender"> <cfoutput query="Gender"> <option value="#Gender#">#Gender#</option> </cfoutput> </select> </td> </tr> <tr> <td> State: </td> <td> <select name="State"> <cfoutput query="State"> <option value="#State#">#State#</option> </cfoutput> </select> </td> </tr> <!--- Updated grouping here ---> <cfoutput query="RatingsQ" group="QuestionID"> <tr> <td> <br> <br> #Question# </td> <td> <cfoutput> <select name="RatingID"> <option value="#RatingID#">#Rating#</option> </select> </cfoutput> </td> </tr> </cfoutput> <!--- Changed this cfoutput ---> <cfoutput query="Questions2"> <tr> <td>#Q#:</td> <td> Answer: <textarea></textarea> </td> </tr> </cfoutput> <tr> <td colspan="2" align="center"><input type="submit" value="Insert"></td> </tr> </table> </cfform> </body> </html>
I also changed lines 85-94 a little to make the output of the Question2 section a little cleaner.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access activation age amd api blogger blogging blogs code combo dani daniweb data database development dos dropdownlist gdata google hacker hardware ibm ibm. news it key linux microsoft module net news open source openoffice pc product programming ps3 red hat research reuse rss security serial sql survey tags trends vista web working xml
- trying to make a survey for school yearbook, need help (PHP)
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- Replace repititious code with a loop? (Visual Basic 4 / 5 / 6)
- DNS Error...Cannot find server when connecting to secure sites (Viruses, Spyware and other Nasties)
Other Threads in the ColdFusion Forum
- Previous Thread: Report Builder : incoming page break
- Next Thread: hash() md5 and url encoding issue


Linear Mode