summaryrefslogtreecommitdiffstats
path: root/js/util.js
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-09-25 19:01:12 +0200
committerByron Jones <bjones@mozilla.com>2012-09-25 19:01:12 +0200
commitb4c57eb52706fd61f3167dc05eccae1fd7c30513 (patch)
tree3bdfde89b1e735f968929c944940b419952bc229 /js/util.js
parent56189de68ab5effc1708ddf65f861842ed48d6ab (diff)
downloadbugzilla-b4c57eb52706fd61f3167dc05eccae1fd7c30513.tar.gz
bugzilla-b4c57eb52706fd61f3167dc05eccae1fd7c30513.tar.xz
Bug 437212: Make page refreshing under Firefox update fields
r=LpSolit, a=LpSolit
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/js/util.js b/js/util.js
index 7ecc2a3d8..6d1f88938 100644
--- a/js/util.js
+++ b/js/util.js
@@ -230,6 +230,27 @@ function bz_selectedOptions(aSelect) {
}
/**
+ * Returns all Option elements that have the "selected" attribute, as an array.
+ * Returns an empty array if nothing is selected.
+ *
+ * @param aSelect The select you want the pre-selected values of.
+ */
+function bz_preselectedOptions(aSelect) {
+ var options = aSelect.options;
+ var selected = new Array();
+ for (var i = 0, l = options.length; i < l; i++) {
+ var attributes = options[i].attributes;
+ for (var j = 0, m = attributes.length; j < m; j++) {
+ if (attributes[j].name == 'selected') {
+ if (!aSelect.multiple) return options[i];
+ selected.push(options[i]);
+ }
+ }
+ }
+ return selected;
+}
+
+/**
* Tells you where (what index) in a <select> a particular option is.
* Returns -1 if the value is not in the <select>
*