Submit Form When Radio Button is Clicked

By | August 27, 2012

In this article, i am going to tell how to auto submit when radio button is clicked. You may have seen in some website, when we click an radio button option ( without clicking on submit button) website will redirects to a page or dynamic changes will happens in that page. Here we are using javascript function submit() is used to submit form values.

submit() javascript function have to be triggered when an option is selected. In onclick event of the radio button we have to use submit() function onclick=”javascript: submit()”.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<html>
<body>
<?php
if(isset($_POST['color']))
{
echo "The Color you have selected ".$_POST['color'];
}
?>
<form action="" method="post">
Select Your Favourite Color:
<input type="radio" name="color" onclick="javascript: submit()" value="red"> Red
<input type="radio" name="color" onclick="javascript: submit()" value="green"> Green
</form>
</body>
</html>

3 thoughts on “Submit Form When Radio Button is Clicked

Leave a Reply

Your email address will not be published. Required fields are marked *

plowstaff-parishad