If anybody can help I would very very appreciate this! The problem is that I’m trying to build a survey! In admin screen there is choice of questions to create (check box, radio, combo and comments) Once admin creates questions with particular radio buttons set, then he can add answers with radio buttons next to it. Then it adds all that to database. For users to see this survey with multiple questions and answers I have created form in which all this is visible. For radio buttons to appear I need to loop through the query which selects all created questions and answers. However, for radio buttons to appear as grouped I use name = #questionID# from query – so that radio buttons will be grouped for each question. My problem is since it is like: <CFLOOP query="radioCheckView"> <INPUT type="Radio" name=" #questionID #" value="<CFOUTPUT>#RadioQuest#</CFOUTPUT>"> <CFOUTPUT>#RadioQuest#</CFOUTPUT><br> </CFLOOP> Once user submits the form, all answers should be inserted into database. How then this radio button can be identified when you submit? <CFIF isDefined("Form.Submit")> <CFOUTPUT query="ViewQuests"> <CFQUERY name="UserInsert" datasource="surveyDB"> INSERT INTO answers (questID, comments, radio) VALUES ( #questID#, '#form.comment#', '#form.??????????? #' – “Don’t know what should I write here this should be a radioButton Name which is mentioned above†) </CFQUERY> </CFIF> Please guys if you know how to solve this problem – help me! THANK YOU VERY VERY MUCH IN ADVANCE!
You should just use '#form.questionID#' Code (markup): What ever radio button is selected, it's value will be passed to form.questionID variable. So thats how you retrieve the radio button value.
... unless they didn't select a radio option at all, in which case the value won't exists and your action page will throw an exception if you are not proactive. Additionally.... *USE CFQUERYPARAM PEOPLE!!!* Anyone with any security knowledge at all could drop your entire database with that code example. Think I am exagerating? Here is an example. What if I create my own form posting to your action page and I passed the following value for questionID 1'; DROP TABLE 'answers' Please for the love of God... everyone... don't make another cfquery without using cfqueryparam. OK, my work is done here.