Answered
Param / evaluate dynamically named radios
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!
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!
