If you have an Html (or HTML5, JSP, PHP, ASP) page with a form element containing a select option and you want to submit the form once an option is selected from the list of the dropdown then you can make use of JavaScript.
Let's see how we can do that with an example, We have a text input type and a dropdown option with select options as add, delete, and update. The user would enter a name and select one of the options to submit the form. We have no buttons. We do this using JavaScript onChange event and submitting the form using this.form.submit()
File: dropdownexample.html<html>
<head>
<title>Submit form on Dropdown list select</title>
</head>
<body>
<form method="get">
Name : <input type="text" id="name" name="name" />
<br /><br />
Option :
<select onchange="this.form.submit()" id="option" name="option">
<option>Select Option</option>
<option>Add</option>
<option>Delete</option>
<option>Update</option>
</select>
</form>
</body>
</html>
This is not an AI-generated article but is demonstrated by a human.
Please support independent contributors like Code2care by donating a coffee.
Buy me a coffee!

Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!