Discussion:
Using CFIF in CFINPUT radio tag
(too old to reply)
lovewebdev
2009-04-03 19:12:36 UTC
Permalink
I'm a little new to using cfinput. I always use HTML input.

I have radio buttons for gender. When the form is submitted, the value is
entered into a db column 1 or 2:
<cfinput name="g" id="g" type="radio" value="1" required="yes"
/>&nbsp;&nbsp;F<cfinput name="g" id="g" type="radio" value="2" />

I want to check one by default depending on the value stored in the db column
when the form loads.

I'm able to use a CFIF statement to check one by default in the HTML radio
like:
<cfif rs.g eq 1>checked="true"</cfif>

but you're not allowed to have cfif in a single cfinput tag.

How do I do it.
GArlington
2009-04-06 11:48:42 UTC
Permalink
Post by lovewebdev
I'm a little new to using cfinput. I always use HTML input.
 I have radio buttons for gender. When the form is submitted, the value is
 <cfinput name="g" id="g" type="radio" value="1" required="yes"
/>&nbsp;&nbsp;F<cfinput name="g" id="g" type="radio" value="2" />
 I want to check one by default depending on the value stored in the db column
when the form loads.
 I'm able to use a CFIF statement to check one by default in the HTML radio
 <cfif rs.g eq 1>checked="true"</cfif>
 but you're not allowed to have cfif in a single cfinput tag.
 How do I do it.
Define a var checkedStatus (or similar), set the value to
'checked="true"' or empty string depending in your if statement
and use <cfinput name="g" id="g" type="radio" value="2"
#checkedStatus# />
Dan Bracuk
2009-04-09 01:40:55 UTC
Permalink
Why don't you simply use an input tag?
--
Dan Bracuk
Loading...