Title: Code Submission: Submit on dropdown select
Last modified: August 21, 2016

---

# Code Submission: Submit on dropdown select

 *  Resolved [ethanpil](https://wordpress.org/support/users/ethanpil/)
 * (@ethanpil)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/code-submission-submit-on-dropdown-select/)
 * Thanks for the great plugin its works really well. I am using it on a woocommerce
   install.
 * I was wondering if you could add an auto submit function so that after I select
   a choice from the dropdown it will automatically load the result instead of me
   havnig to click the button. The code is quite simple, here is what I did, you
   can probably make it betetr by adding a checkbox in the admin to choose if the
   user wnats thins feature…
 * In the latest version starting at line 90: The changes on each line are noted
   with a //<- comment
 *     ```
       $args = array(
       				'show_option_all'    => false,
       				'show_option_none'   => ' ', // <- Added a space to make the first choice blank
       				'orderby'            => $orderby,
       				'order'              => $ascdsc,
       				'show_count'         => $showcount,
       				'hide_empty'         => 1,
       				'child_of'           => $childof,
       				'exclude'            => $exclude,
       				'echo'               => 0, // <- dont output immediately so we can pare it later
       				//'selected'           => 0,
       				'hierarchical'       => $hierarchical,
       				'name'               => $taxonomy_object->query_var,
       				'id'                 => 'lct-widget-'.$tax,
       				//'class'              => 'postform',
       				'depth'              => 0,
       				//'tab_index'          => 0,
       				'taxonomy'           => $tax,
       				'hide_if_empty'      => true,
       				'walker'			=> new lctwidget_Taxonomy_Dropdown_Walker()
       			);
       			echo '<form action="'. get_bloginfo('url'). '" method="get">';
       			$select = wp_dropdown_categories($args); //<- store in var
       			$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); //<- add the javascript to submit on change
       			echo $select;  //<- output the select
       			//<-- hide the submit button echo '<input type="submit" value="go &raquo;" /></form>';
       		}
       ```
   
 * [https://wordpress.org/plugins/list-custom-taxonomy-widget/](https://wordpress.org/plugins/list-custom-taxonomy-widget/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Nick Halsey](https://wordpress.org/support/users/celloexpressions/)
 * (@celloexpressions)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/code-submission-submit-on-dropdown-select/#post-4586474)
 * Thanks for the submission. Unfortunately, auto-submitting dropdowns are not keyboard-
   accessible, so their use (despite being frequent and nice for most users) is 
   generally discouraged. Feel free to fork the plugin with this feature, though!
 *  [hussong](https://wordpress.org/support/users/hussong/)
 * (@hussong)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/code-submission-submit-on-dropdown-select/#post-4586479)
 * Nick, I understand your accessibility concern and applaud your acceptance of 
   a non-accessible fork 🙂
 * Ethan, thanks for sharing, just made my day!
 *  [hussong](https://wordpress.org/support/users/hussong/)
 * (@hussong)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/code-submission-submit-on-dropdown-select/#post-4586480)
 * By the way, when you hide the submit button
 * `//<-- hide the submit button echo '<input type="submit" value="go »" /></form
   >';`
 * you’ll still want to echo the closing form tag somewhere.
 * Just stumbled upon this since I had several taxonomy widgets in the sidebar and
   they would submit all at once…
 * Or you could just echo the submit button wrapped in noscript to hide it
 * `echo '<noscript><input type="submit" value="go »" /></noscript></form>'; // 
   <- show button for noscript`
 * as seen on [http://codex.wordpress.org/Function_Reference/wp_dropdown_categories](http://codex.wordpress.org/Function_Reference/wp_dropdown_categories)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Code Submission: Submit on dropdown select’ is closed to new replies.

 * ![](https://ps.w.org/list-custom-taxonomy-widget/assets/icon.svg?rev=1225454)
 * [List Custom Taxonomy Widget](https://wordpress.org/plugins/list-custom-taxonomy-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-custom-taxonomy-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-custom-taxonomy-widget/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [hussong](https://wordpress.org/support/users/hussong/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/code-submission-submit-on-dropdown-select/#post-4586480)
 * Status: resolved