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
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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.