Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

edit a form - retrieve values from db and set checkboxes to reflect va

Status
Not open for further replies.

leeolive

Programmer
May 14, 2002
46
GB

Hi

I have a feedback form which user completes and data is submitted to db. I then want to allow user to edit this form so I retrieve values from db and populate the textboxes. This is working fine. My question is how do I set checkboxes and radio buttons to reflect these values?

It must be something like 'if value is ?? then check the box', but what is the correct syntax and is this code placed within the actual radio box/checkbox?

ie. Radio: <input type=&quot;radio&quot; name=&quot;Gender&quot; <%if strGender = &quot;1&quot; then value=&quot;Check Checkbox&quot; %> />Male

Checkbox Mail <input type=&quot;checkbox&quot; name=&quot;ReceiveInfoByMail&quot; value=&quot;<%=strReceiveInfoByMail%>&quot; />

Thanks!
Lee
 
<input type=&quot;radio&quot; name=&quot;Gender&quot; value=&quot;Male&quot; <%if strGender = &quot;1&quot; then %> checked <%end if%>>Male

I believe that is the right syntax.

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
While the above would work in most browsers today it is not valid XHTML therefore may not run in future browsers. The bellow syntax is valid XHTML i think.

<input type=&quot;radio&quot; name=&quot;Gender&quot; value=&quot;Male&quot; <%if strGender = &quot;1&quot; then %> checked=&quot;checked&quot; <%end if%> />

kind regards

Angus

Angus
 
Thanks Angus and Chopstik. What a relief - all working!
Much appreciated.
Cheers
Lee
 
Was not aware of that, Gus121. Thanks for the heads up, I can see that I'm going to be doing some research when/if I get some spare time... [thumbsup]

-----------------------------------------------------------------------------------------------------
&quot;If you can't explain something to a six-year-old, you really don't understand it yourself.&quot;
-- Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top