Link to home
Start Free TrialLog in
Avatar of alicia1234
alicia1234Flag for United States of America

asked on

How do I pre-populate (set) the value of a radio button in a form?

I have a form that I use to create a new recipe. I have a radio button group like this:


I want to use the same form to modify an existing recipe. I know how to pull in the text fields for the recipe (from my database) so that the form is populated with the "existing" data.
But I don't know how to pull in the stuff for my radio buttons.

I have radio buttons for the difficulty: easy, moderate, etc.
In my database, I have a field (rs_RecipeDetails.Difficulty) that contains, for example, the word "easy".

The code for my buttons is:
<input type="radio" name="Difficulty" value="Easy" />
<input type="radio" name="Difficulty" value="Moderate" />
etc.
                         
How do I set the radio button for "easy" ? (That is, how do I preset it based on what is already in the database field "Difficulty"?


ASKER CERTIFIED SOLUTION
Avatar of bwasyliuk
bwasyliuk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alicia1234

ASKER

It doesn't ... ;-(

Here's what I put in:
<input type="radio" name="Difficulty" value="Easy"
<cfoutput>
#IIF(rs_RecipeDetails.Difficulty eq "Easy",
DE("Selected"),DE(""))#
</cfoutput>/>

For my test, I did verify that "Difficulty" is, indeed, "Easy" with a capital E.
What's the "DE" ??
And where would I look up "IIF" ... it's not in HTML reference ...
In the accepted answer: I changed "Selected" to "checked" (after examining the help for the HTML input tag) and then it worked correctly.
Thanks!