Javascript error Error: Call Error: document.forms is not a function

When running the Javascript attached below I receive the following error message in Notes 6 Browser, however I receive no errors when running the script in Internet Explorer:

Javascript error

Error: Call Error: document.forms is not a function

The script (part of)- below, will call one of two functions depending on which conditions are met. These functions will in turn ‘click’ on a Hotspot link which then triggers some formula language.

if(reqAns == “1” ) {

var confirmstatus = confirm( Header)}

if (confirmstatus == true && document.forms[0].AnStatus.value == “3”) {

javascript:SubmitSurveyAnonymously() }

if (confirmstatus == true && document.forms[0].AnStatus.value == “2”) {

javascript:SubmitSurveys()}

if (confirmstatus == true && document.forms[0].AnStatus.value == “1”) {

javascript:SubmitSurveys()}

if (confirmstatus == true && document.forms[0].AnStatus.value == " ") {

javascript:SubmitSurveys()}

if (reqAns == “0” && document.forms[0].AnStatus.value == “3”) {

javascript:SubmitSurveyAnonymously() }

if (reqAns == “0” && document.forms[0].AnStatus.value == “2”) {

javascript:SubmitSurveys()}

if (reqAns == “0” && document.forms[0].AnStatus.value == “1”) {

javascript:SubmitSurveys()}

if (reqAns == “0” && document.forms[0].AnStatus.value == " ") {

javascript:SubmitSurveys()}

These are the two functions:

function SubmitSurveys()

{

for (var i=0;i<document.links.length;i++)

{

if (document.links[i].name==“SubmitSurvey”)

{

document.links[i].onclick();

}

}

}

function SubmitSurveyAnonymously()

{

for (var i=0;i<document.links.length;i++)

{

if (document.links[i].name==“SubmitSurveyAnon”)

{

document.links[i].onclick();

}

}

}

Any help in trying to understand and remedy this problem will be greatly appreciated. Many Thanks.

Subject: Javascript error Error: Call Error: document.forms is not a function

Neil,

What kind of field is AnStatus? Your code will only work if AnStatus is a text input field and users are actually typing in a 1, 2, 3, or a space or if it is a hidden field and the value is hardcoded.

If AnStatus is a dropdown select box type of field, then your JavaScript is wrong.

Ken

Subject: RE: Javascript error Error: Call Error: document.forms is not a function

I’d actually suspect that the problem is related to the “javascript:” pseudoURLs in the if blocks. A function call in JavaScript (ECMAScript) is:

[object.]functionName(args)

so

javascript:SubmitSurveys()

should be

SubmitSurveys()

Code that works in Internet Explorer isn’t necessarily working code, and error messages in a JavaScript runtime are to be read as “something went wrong somewhere”, not “here’s the problem right … here”.