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 »" /></form>'; }
https://www.ads-software.com/plugins/list-custom-taxonomy-widget/
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Code Submission: Submit on dropdown select’ is closed to new replies.