SHARE
Facebook X Pinterest WhatsApp

How To Use JavaScript To Auto-Submit Dropdowns, With No Submit Button

Written By
thumbnail
Scott Clark
Scott Clark
Sep 9, 2010

As a developer, I not only create websites, but I browse and interact on the web each day. One thing that I have found that is irritating, as a user, is when you are required to choose a selection from a dropdown form, and once selected, it does not autosubmit. In this tutorial we will show you have to use JavaScript to do just that.


Here is an example of such a form without an auto-submit. When you make a selection, you are required to submit the form using the standard submit button:




Now here is the same form with an auto-submit JavaScript in action:



Although there is no action attached to this form, you can see that it is submitted by the actions of the web browser (i.e. in the first one, no action occurs when you make a selection…in the second, you can see that the form is submitted).


Here is the code that is used for the form shown above. Essentially, the only difference in the form above is simply an onchange statement, along with a noscript tag that allows browsers that are not JavaScript-enabled to still function:

<form>
<select name=’myfield’ onchange=’this.form.submit()’>
  <option selected>Milk</option>
  <option>Coffee</option>
  <option>Tea</option>
</select>
<noscript><input type=”submit” value=”Submit”></noscript>
</form>

Note that the onchange event can be added to any form, and any element, including radio buttons, select elements, and even text fields. Make the world a better place and use an auto-submit form whenever you create a form. By using the noscript tag, any user can submit the form, and those of us with JavaScript enabled (which is most of us) will be saved the frustration and effort of submitting a form manually. I know it’s not much, but it adds a touch of professionalism and interaction to your site that your visitors will appreciate.

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.