diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2011-01-31 13:49:10 +0100 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2011-01-31 13:49:10 +0100 |
commit | ceea734a6e745087356b0119fc7a4acac821c5aa (patch) | |
tree | 6b1e566e1d5ace9f044cff0be9acf2ae67430f99 /lib/scripts | |
parent | 06756ad2b150ae2ce564043d0e7f02de5fa22b59 (diff) | |
download | rpg-ceea734a6e745087356b0119fc7a4acac821c5aa.tar.gz rpg-ceea734a6e745087356b0119fc7a4acac821c5aa.tar.bz2 |
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.
Diffstat (limited to 'lib/scripts')
-rw-r--r-- | lib/scripts/script.js | 28 |
1 files 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'; + } + } + } }); /** |