I have a simple javascript function found in a separate .js file:
function test(doc_obj)
{
var x = document.getElementById(doc_obj);
//x is a document object that has been initialized w/the values from SRMForm
var text = "";
var i;
for (i = 0; i < x.length ;i++) {
text += x.elements.value + "<br>";
}
console.log(text);
}
When I invoke the javascript function in the actual form (<form id="SRMForm" method="post" action="./SRMFormProcess.php">)
via <select id="u4" class="u4" name="URL" onchange="test(this.document)"> the browser web developer console reports back
that x is null in function test.
So how do I properly pass the form object to the test function?
function test(doc_obj)
{
var x = document.getElementById(doc_obj);
//x is a document object that has been initialized w/the values from SRMForm
var text = "";
var i;
for (i = 0; i < x.length ;i++) {
text += x.elements.value + "<br>";
}
console.log(text);
}
When I invoke the javascript function in the actual form (<form id="SRMForm" method="post" action="./SRMFormProcess.php">)
via <select id="u4" class="u4" name="URL" onchange="test(this.document)"> the browser web developer console reports back
that x is null in function test.
So how do I properly pass the form object to the test function?