aboutsummaryrefslogtreecommitdiffstats
path: root/offline-submit/collect-inputs.js
diff options
context:
space:
mode:
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;