Skip to main content
March 19, 2009
Answered

Param / evaluate dynamically named radios

  • March 19, 2009
  • 2 replies
  • 354 views
Greetings!

Have an HTML form that names radio buttons according to a query output loop and DB id. So, form could have the following radio names:
form.q12
form.q15
form.q27

I need to insure that all questions are answered (server-side), and the problem is that if a user does not select a radio button, it never gets back to CF once the form is submitted. So, I need to either param the form variables, or use a isDefined function. This is giving me fits.

My processing logic is to loop thru the same query results that generated the questions (to get the same ids) and either param:
<cfparam name="#evaluate('form.q' & questions.questionID)#" default="">

or use an isDefined function:
<cfif NOT isDefined("#evaluate('form.q' & questions.questionID)#")>

neither work, returning 'form.q12' is not defined' error, which is funny because thats exactly what I want to know, but not as an error :-)

I thought I could try and catch isDefined function, and if it throws an error, assume the particular question was not submitted, but this seems like a silly solution. I'd appreciate if anyone has a recommendation. Thanks!
This topic has been closed for replies.
Correct answer Newsgroup_User
that's because you are trying to evaluate form.qXX = get the value of
that field when you use evaluate() function.

you have your query at the top of the form processing code:
<cfquery name="questions" ...>
...
</cfquery>

then just output it and set your cfparams without evaluate():
<cfoutput query="questions">
<cfparam name="form.q#questions.questionID#" default="">
</cfoutput>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

2 replies

March 20, 2009
[slaps forehead]... Talk about overthinking something...

Worked great. Thanks, Azadi!
Newsgroup_UserCorrect answer
Inspiring
March 20, 2009
that's because you are trying to evaluate form.qXX = get the value of
that field when you use evaluate() function.

you have your query at the top of the form processing code:
<cfquery name="questions" ...>
...
</cfquery>

then just output it and set your cfparams without evaluate():
<cfoutput query="questions">
<cfparam name="form.q#questions.questionID#" default="">
</cfoutput>

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/