Jump to content

Archived

This topic is now archived and is closed to further replies.

xious

recalling radio button data

Recommended Posts

I have a contact info database with Yes/No radio buttons. I have added a link to edit each entry, and on that link, all the fields are filled with the current values. However, I do not know how to have the radio buttons checked with the current values. How would I do that? I have all the text fields filled out with the echo commands, but I don't know how to change the radio buttons. Any info would be appreciated.

X

Share this post


Link to post
Share on other sites
In order to make a radio button checked you have to add "checked="checked"" to the radio button tag.
This will do the job:
[code]
<?php
//Let's say 'yes' is 1 and 'no' is 0
if($radio == 0){$radiotext = "";};
elseif($radio == 1){$radiotext = 'checked="checked"';};
?>
<input type="radio" name="yesno" <?php echo($radiotext); ?>>
[/code]
Hope it helps :)

Orio.

Share this post


Link to post
Share on other sites
That's sort of what I needed, but the radio buttons are multiple (Yes, No, and Maybe), not just checked for Yes, unchecked for no. So how would I do it that way? I think I would have to use different variables, but it is not liking either my variables or my syntax.

Share this post


Link to post
Share on other sites
I ended up getting it. Thanks for giving me a starting point Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.