aboutsummaryrefslogtreecommitdiffstats
path: root/offline-submit/collect-inputs.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-01-13 00:21:23 +0100
committerMatěj Cepl <mcepl@redhat.com>2010-01-13 00:21:23 +0100
commit5333869aac2dbd71c91727dbca6aee1a46b3cdb1 (patch)
treefccd59b1c901393c13c63ab12db9c8db4dd7c113 /offline-submit/collect-inputs.js
parent7ae28278cf7f4920175058971dee2b06b0e331b8 (diff)
downloadbugzilla-triage-5333869aac2dbd71c91727dbca6aee1a46b3cdb1.tar.gz
Starting to work on the offline capabilities.
Diffstat (limited to 'offline-submit/collect-inputs.js')
-rw-r--r--offline-submit/collect-inputs.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/offline-submit/collect-inputs.js b/offline-submit/collect-inputs.js
new file mode 100644
index 0000000..d6a2b47
--- /dev/null
+++ b/offline-submit/collect-inputs.js
@@ -0,0 +1,45 @@
+bzPage.prototype.collectInputs = function (form) {
+
+// form.elements array of all controls ... no, forEach though
+// INPUT, SELECT, TEXTAREA, and BUTTON
+// each interesting control of them have NAME and VALUE
+// You can access a particular element by using either an index or the element name or id.
+//
+// https://developer.mozilla.org/en/DOM/form
+// form.elements.querySelectorAll("*[name]")
+
+ var x=this.dok.getElementById("myForm");
+for (var i=0;i<x.length;i++)
+{
+document.write(x.elements[i].value + ", " + x.elements[i].tagName + ", " + x.elements[i].name);
+document.write("<br />");
+}
+
+}
+
+// INTERESTING: http://www.quirksmode.org/js/forms.html
+
+// Example onsubmit handler
+
+function checkscript() {
+ if (some value is/is not something) {
+ // something is wrong
+ alert('alert user of problem');
+ return false;
+ }
+ else if (another value is/is not something) {
+ // something else is wrong
+ alert('alert user of problem');
+ return false;
+ }
+
+ // If the script makes it to here, everything is OK,
+ // so you can submit the form
+
+ return true;
+}
+
+// with XPCNativeWrappers you cannot use document.formname.inputname.value
+var form = document.forms.namedItem("gs");
+var input = form.elements.namedItem("q");
+var q = input.value;