• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Param / evaluate dynamically named radios

Guest
Mar 19, 2009 Mar 19, 2009

Copy link to clipboard

Copied

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!
TOPICS
Advanced techniques

Views

296

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 19, 2009 Mar 19, 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/

Votes

Translate

Translate
LEGEND ,
Mar 19, 2009 Mar 19, 2009

Copy link to clipboard

Copied

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/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 20, 2009 Mar 20, 2009

Copy link to clipboard

Copied

LATEST
[slaps forehead]... Talk about overthinking something...

Worked great. Thanks, Azadi!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation