Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please HELP!!! Survey building problem (passing variable)

Status
Not open for further replies.

rrusik

Programmer
Mar 23, 2008
2
0
0
AU
Hello everybody!!!
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="Checkbox" name="selCheck" value="<CFOUTPUT>#checkBoxQuest#</CFOUTPUT>"> <CFOUTPUT>#checkBoxQuest#</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”
)
</CFQUERY>

</CFIF>


Please guys if you know how to solve this problem – help me!

THANK YOU VERY VERY MUCH IN ADVANCE!
 
There are a number of approaches you could use here, but you'll probably have to change your form first.

It appears you are using the question as the name of the form field. Since the question likely contains spaces, this isn't going to work.

You can prefix the form variable with something that will be unique in the form, and follow it by a numeric ID. So, for instance, name="Question_#questID#". You can then use the Eval function to get the value of the field in your query... ie: #Eval("form.Question_#questID#")#.

Since the user might not answer all of the questions, it might be prudent to check for the existance of the variable before going into the query.

Good Luck
 
RocketDan YOU ROCK!!!!!!!!!!!! Everything is working now! YOU ARE THE BEST !!!!! Thank you very very much to you!!!!!!

"Eval" thing never actually heard of it and because of you now I know something about it!

Thank you very much once again,
Best wishes,
Rusik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top