Solved

input type=radio question

Posted on 2001-08-04
3
257 Views
Last Modified: 2006-11-17
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
0
Comment
Question by:volvo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Expert Comment

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

etc
0
 
LVL 15

Accepted Solution

by:
a.marsh earned 30 total points
ID: 6351981
Or why not make life easier and change the code to:

for($i = 1; $i < 4; $i++){
  echo "<input type=radio value=$i name=template";
  if($row[template] == $i) echo " checked";
  echo ">";
}


:o)

Ant
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6352809
Glad to have helped. :o)

Thanks for the A!

Ant
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question