diff options
author | mkanat%bugzilla.org <> | 2008-11-07 18:34:39 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-11-07 18:34:39 +0100 |
commit | 63be194996849202878c4a87e4c68a25d1976d3e (patch) | |
tree | 657fbe1458ce256015a832251219669070886e1e /js/util.js | |
parent | ebd2e3a29a893e1ea26899bac53296fc6422f47c (diff) | |
download | bugzilla-63be194996849202878c4a87e4c68a25d1976d3e.tar.gz bugzilla-63be194996849202878c4a87e4c68a25d1976d3e.tar.xz |
Bug 308253: Ability to add select (enum) fields to a bug whose list of values depends on the value of another field
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat
Diffstat (limited to 'js/util.js')
-rw-r--r-- | js/util.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js index feef8fe41..86924210c 100644 --- a/js/util.js +++ b/js/util.js @@ -219,3 +219,37 @@ function bz_valueSelected(aSelect, aValue) { return false; } +/** + * Tells you where (what index) in a <select> a particular option is. + * Returns -1 if the value is not in the <select> + * + * @param aSelect The select you're checking. + * @param aValue The value you want to know the index of. + */ +function bz_optionIndex(aSelect, aValue) { + for (var i = 0; i < aSelect.options.length; i++) { + if (aSelect.options[i].value == aValue) { + return i; + } + } + return -1; +} + +/** + * Used to fire an event programmatically. + * + * @param anElement The element you want to fire the event of. + * @param anEvent The name of the event you want to fire, + * without the word "on" in front of it. + */ +function bz_fireEvent(anElement, anEvent) { + // IE + if (document.createEventObject) { + var evt = document.createEventObject(); + return anElement.fireEvent('on' + anEvent, evt); + } + // Firefox, etc. + var evt = document.createEvent("HTMLEvents"); + evt.initEvent(anEvent, true, true); // event type, bubbling, cancelable + return !anElement.dispatchEvent(evt); +} |