Submit Form When Drop-down List box is Selected

By | August 27, 2012

As like when radio button is clicked, form will be submitted. We can also make auto submit when an item in drop-down list is selected. The purpose of radio button and drop down box is quite simple, both of this html attribute allows us only to select only one option from the given option. Dropdown box will used, when number of options are more and usage of drop-down box will reduce the size of webpage.

Here javascript submit() function is used in onchange event. Onchange of the dropdown box item, the submit function will be triggered.

 
 

Here is the code
 
[code type=php]

<html>
<body>
<?php
if(isset($_POST[‘color’]))
{
echo “The Color you have selected <b>”.$_POST[‘color’].”</b><br><br>”;
}
?>
<form action=”” method=”post”>
Select Your Favourite Color:
<select name=”color” onchange=”javascript: submit()”>
<option>—</option>
<option>Red</option>
<option>Blue</option>
<option>White</option>
</select>
</form>
</body>
</html>

[/code]

 

4 thoughts on “Submit Form When Drop-down List box is Selected

    1. prasad Post author

      give action=”new.php” in first page

      new.php
      if(isset($_POST[‘color’]))
      {
      echo “The Color you have selected “.$_POST[‘color’];
      }

      Reply
  1. κατασκευη ιστοσελιδων

    great post, very informative. I’m wondering why the opposite
    specialists oof this sector don’t notice this.

    You must proceed your writing. I’m confident, you’ve a great readers’ base already!

    Reply

Leave a Reply to prasad Cancel reply

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

feminacy-mortarless