Jump to content

recalling radio button data


xious

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
Link to comment
https://forums.phpfreaks.com/topic/7491-recalling-radio-button-data/
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.

Archived

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

×
×
  • Create New...

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.