From 63be194996849202878c4a87e4c68a25d1976d3e Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 7 Nov 2008 17:34:39 +0000 Subject: 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 r=bbaetz, a=mkanat --- js/util.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'js/util.js') 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 + * + * @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); +} -- cgit v1.2.3-24-g4f1b