...

View Full Version : Code for radio button



newphpcoder
12-09-2010, 07:12 AM
Good day!

I never used radio button. Now I need to add radio button in my webpage. Radio button 1 is mother and radio button 2 is child. Is it in my database it is only 1 field or separate field one for mother and one for child?

Kindly give me a code for radio button.

Thank you...

poyzn
12-09-2010, 07:18 AM
<form>
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</form>

find more with google (http://www.google.com/search?q=html+radio+button).

durangod
12-09-2010, 07:20 AM
not sure im understanding what you said about db, but here is a sample of a radio code input form you can modify if you need to..



<form action="result.php" method="post">
Answer 1 <input type="radio" name="ans" value="mother" /><br />
Answer 2 <input type="radio" name="ans" value="child" /><br />
<input type="submit" value="submit" />
</form>


hope that helps

newphpcoder
12-09-2010, 07:30 AM
not sure im understanding what you said about db, but here is a sample of a radio code input form you can modify if you need to..



<form action="result.php" method="post">
Answer 1 <input type="radio" name="ans" value="mother" /><br />
Answer 2 <input type="radio" name="ans" value="child" /><br />
<input type="submit" value="submit" />
</form>


hope that helps

I want is if the user choose mother it should save in the database. and also the user could not click both radio button.

Thank you

durangod
12-09-2010, 07:36 AM
by default radio buttons are designed to only allow one choice only, do you already have a table set up in your db for this value to be written to.

newphpcoder
12-09-2010, 07:42 AM
by default radio buttons are designed to only allow one choice only, do you already have a table set up in your db for this value to be written to.

Yes I have...

poyzn
12-09-2010, 11:33 AM
<form>
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
</form>

find more with google (http://www.google.com/search?q=html+radio+button).

A user's choice is in the $_POST['sex'] variable if your form method is post.
if user checks male radio button then $_POST['sex'] == 'male'



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum