Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE/Firefox woes... 1

Status
Not open for further replies.

gruvn

Programmer
Oct 15, 2004
24
CA
Hey all,

I'm not very proficient with javascript so I was wondering if someone could help me figure out why the following code works in IE, but not in Firefox.

The error i get is that "document.forms is not a function" - pointing to the 2nd line of the following...

function addSection() {
var theForm = document.forms(0);
if (theForm.queryValue.value == '')
alert("Please enter a query value.");
else if (theForm.queryField.options.length < 1)
alert("Please select an identifiable layer (Step 1)");
else {
var fieldName, fieldType, quoteString, tempIndex;
quoteString = '';
tempIndex = theForm.queryField.value.indexOf("|", 0);
fieldName = theForm.queryField.value.substring(tempIndex + 1);
fieldType = theForm.queryField.value.substring(0, tempIndex);
if (fieldType == 12) { quoteString = "\'"; }
addString(fieldName + theForm.queryOperator.value + quoteString + theForm.queryValue.value + quoteString);
theForm.queryValue.value = '';
}

Any thoughts?

Thanks!
 
Using parentheses is a great way to pass parameters to a function. It's not, however, a great way to reference an array. That's what [] is for. Try this:

var theForm = document.forms[0];

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Thanks clFlaVA!

That was it!

gruvn

PS: Family Guy rules...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top