Jump to content


Photo

recalling radio button data


  • Please log in to reply
3 replies to this topic

#1 xious

xious
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 15 April 2006 - 04:55 PM

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

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 April 2006 - 07:36 PM

In order to make a radio button checked you have to add "checked="checked"" to the radio button tag.
This will do the job:
<?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); ?>>
Hope it helps :)

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 xious

xious
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 15 April 2006 - 09:03 PM

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.

#4 xious

xious
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 15 April 2006 - 09:25 PM

I ended up getting it. Thanks for giving me a starting point Orio.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users