Forum Moderators: coopster

Message Too Old, No Replies

radio buttons, multiples of

radio buttons in the same form

         

odd_thomas

9:25 pm on Jul 3, 2006 (gmt 0)

10+ Year Member



Hello everyone,

I have a small problem. I have got a simple form that has one row in a while loop that presents data from a specified database, in this row i have two radio buttons, one with the value of 'yes', and the other, 'no', the idea is that one of the colums in the database is holding the value either yes or no. But when i try to echo this effect to the screen using an if() clause, rather than a ternary operator, which is successful - when i have the two options both set to 'no', or 'yes', only the first instance of gets echoed, the second is ignored.

this is how the code is written:

if ($row->viewable == "yes")
{
echo '<input type="radio" checked value="yes" name="[]">';
echo '<input type="radio" value="no" name="[]">';
}
else
{
echo...inverted of the other
}

could anyone advise on what im doing wrong.

Thanks

Odd

omoutop

5:48 am on Jul 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<input type="radio" value="yes" name="viewable" <? if ($row->viewable == "yes"){echo "checked";}?> >
<input type="radio" value="no" name="viewable" <? if ($row->viewable == "no"){echo "checked";}?> >