blob: d6a2b47a3e49f402c2ce14a7822cb42738e2ee3a (
plain) (
tree)
|
|
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;
|