How To Submit Form In Select Option?


In this tutorial, We will learn How to submit form on change of dropdown list? You can use other elements e.g. checkbox, radio, select, etc. using Client-side script. we learn submit form on select change.

When we select a value, as soon as we select it is submitted, we will learn it in this tutorial. today learn how to submit dropdowns in two ways, which are both very easy, we will see below.

Example: 1

This code is an only one line for code see below:

<select name="sortby" onchange="this.form.submit()">
       <option value="">Featured</option>
       <option value="asc" >Price: Low to High</option>
        <option value="desc">Price: High to Low</option>                                   
</select>
Populate Drop Down List From Databa...
Populate Drop Down List From Database In PHP With Source Code 2020
Example: 2

This code is used in javascript form submitted. this code is an easy see below: 

<form method='post' action='' id='myform'>
<select name='sortby' onchange='submitForm();'> 
  <option value="">Featured</option>
       <option value="asc" >Price: Low to High</option>
        <option value="desc">Price: High to Low</option>
 </select> 
</form>
 
<!-- Script --> 
<script type='text/javascript'> 
function submitForm(){ 
  // Call submit() method on <form id='myform'>
  document.getElementById('myform').submit(); 
} 
</script>

I hope it can help you...

Leave a Reply

Your privacy will not be published. Required fields are marked *

We'll share your Website Only Trusted.!!

close