alicia1234
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.Difficul ty) 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"?
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.Difficul
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What's the "DE" ??
ASKER
And where would I look up "IIF" ... it's not in HTML reference ...
ASKER
In the accepted answer: I changed "Selected" to "checked" (after examining the help for the HTML input tag) and then it worked correctly.
Thanks!
Thanks!
ASKER
Here's what I put in:
<input type="radio" name="Difficulty" value="Easy"
<cfoutput>
#IIF(rs_RecipeDetails.Diff
DE("Selected"),DE(""))#
</cfoutput>/>
For my test, I did verify that "Difficulty" is, indeed, "Easy" with a capital E.