Link to home
Start Free TrialLog in
Avatar of volvo
volvo

asked on

input type=radio question

Hello

I have a field in my table that is called "template" and i have a form with 3 radio buttons.

When the form is loaded it has to check a radio button depending on the value.
When i submit the form it has to write the value into my table field "template".

The code i try to use looks like:

echo "<input type=radio value=1 name=template ".if ($row[template]==1) echo "checked".">";
echo "<input type=radio value=2 name=template ".if ($row[template]==2) echo "checked".">";
echo "<input type=radio value=3 name=template ".if ($row[template]==3) echo "checked".">";

Why does this not work:

I always get a parse error
Avatar of cynicz
cynicz

change that to
echo "<input type=radio value=1 name=template" . ($row[template]==1) ? " checked" : "" . ">";

etc
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad to have helped. :o)

Thanks for the A!

Ant