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()”.



[code type=php]

<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>

[/code]

3 thoughts on “Submit Form When Radio Button is Clicked

Leave a Reply

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

freeway-lozenge