If you have a Html (or Html5, JSP, PHP, ASP) page with a form element containing select option and you want to submit the form once a 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 option 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>
More Posts related to JavaScript,
- Get Current time in GMT/UTC using JavaScript
- How to get current URL Location using Javascript HTML
- Excel Fix: SECURITY RISK Microsoft has blocked macros from running because the source of this file is untrusted.
- Convert Javascript object to JSON String example
- Fix: ReferenceError: require is not defined in ES module scope [Node]
- [JavaScript] Remove all Newlines From String
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- Fix: Error: error:0308010C:digital envelope routines::unsupported NodeJs/Vue/React
- Pure JavaScript Digital Clock Widget to get GMT/UTC Time Now
- Fix: npm vs code eacces permission denied unlink /usr/local/bin/code
- Power of Print Statements in JavaScript: A Comprehensive Guide
- [javaScript] Convert text case to lowercase
- JavaScript: Count Words in a String
- JavaScript date in yyyy-MM-dd format
- How to send email from JavaScript HTML using mailto
- How to get UTC (GMT) time using JavaScript
- JavaScript: Generate Random Numbers between 1 and 3
- How to get query string in JavaScript HTML location.search
- Fix: Uncaught ReferenceError: exit is not defined - Node.js REPL
- Detect if Cookies are enabled using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- Send Extra Data with Ajax Get or Post Request
- Loading previous page using html button using JavaScript
- 10 ways to Convert String to a Number in JavaScript
- JavaScript: Check if variable is a number
More Posts:
- Changing Android Intent Tittle using java code - Android
- Make Notepad++ the default App for .txt file extensions - NotepadPlusPlus
- Enable macOS Stage Manager - MacOS
- Java: Reference List of Time Zones and GMT/UTC Offset - Java
- [fix] SharePoint: We only support embedding content from secure websites - SharePoint
- Notepad++ : Cannot load 64 or 32bit plugin Error. - NotepadPlusPlus
- SharePoint List excel import - This table exceeds the maximum number of supported rows - SharePoint
- Update Powershell Using Command Line - Powershell