From ceea734a6e745087356b0119fc7a4acac821c5aa Mon Sep 17 00:00:00 2001 From: Andreas Gohr <gohr@cosmocode.de> Date: Mon, 31 Jan 2011 13:49:10 +0100 Subject: [PATCH] Made the auto submit script more versatile When a <select> tag has the class "quickselect", this script will automatically submit its parent form when the select value changes. It also hides the submit button of the form. --- lib/scripts/script.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/scripts/script.js b/lib/scripts/script.js index c79c9b683..b9b324f96 100644 --- a/lib/scripts/script.js +++ b/lib/scripts/script.js @@ -460,19 +460,29 @@ addInitEvent(function(){ }); /** - * Add the event handler to the actiondropdown + * Autosubmit quick select forms + * + * When a <select> tag has the class "quickselect", this script will + * automatically submit its parent form when the select value changes. + * It also hides the submit button of the form. * * @author Andreas Gohr <andi@splitbrain.org> */ addInitEvent(function(){ - var selector = $('action__selector'); - if(!selector) return; - - addEvent(selector,'change',function(e){ - this.form.submit(); - }); - - $('action__selectorbtn').style.display = 'none'; + var selects = getElementsByClass('quickselect',document,'select'); + for(var i=0; i<selects.length; i++){ + // auto submit on change + addEvent(selects[i],'change',function(e){ + this.form.submit(); + }); + // hide submit buttons + var btns = selects[i].form.getElementsByTagName('input'); + for(var j=0; j<btns.length; j++){ + if(btns[j].type == 'submit'){ + btns[j].style.display = 'none'; + } + } + } }); /** -- GitLab