Welcome Guest, Not a member yet? Register   Sign In
Radio Button
#1

[eluser]patsm[/eluser]
I know this is something simple, I just can't seem to figure it out.

I have a form with several sets of radio buttons. For example, one set is named leftTopNav with values "weather" and "clock". This is an administration page where user can check which to display.

In my database, the field leftTopNav is either weather or clock.

When user is back at the administration page, I want the the radio button checked based what is stored in database. Something like this:

<input type="radio" name="leftTopNav" value="weather" <? if ($leftTopNav ='weather') { echo 'checked'};?>>Weather

It is the if statement that is not correct and I'm not sure what is wrong. And yes, when I echo $leftTopNav, it is returning what is stored in the database. I just need to get the if part right to make it check if weather = weather.

Thanks for your help!
#2

[eluser]Dready[/eluser]
Hello,

try
Code:
<? if ($leftTopNav =='weather') { echo 'checked'};?>

double "=" sign
#3

[eluser]patsm[/eluser]
Thanks, that worked!




Theme © iAndrew 2016 - Forum software by © MyBB