Written by me@grafxflow
09 Jun, 2009
0
2,362
Here is one way of detecting a radio button has been pressed using php. So for this example we have three radio buttons on the form.
<form id="form1" name="form1" method="post" action="">
<label>
<input name="radiobutton" type="radio" value="option 1" onchange="this.form.submit();"/>
canteen
</label>
<p>
<label>
<input name="radiobutton" type="radio" value="option 2" onchange="this.form.submit();" />
quarters
</label>
</p>
<p>
<label>
<input name="radiobutton" type="radio" value="option 3" onchange="this.form.submit();"/>
server room
</label>
</p>
</form>
The php...
<?php
if ($_POST['radiobutton'] == 'option 1') {
echo 'option 1 radio button pressed';
}
?>
12 Jan, 2010
24 Nov, 2013
07 Nov, 2012
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 166,139
Views: 40,218
Views: 36,940
Views: 33,525