Forum Moderators: open

Message Too Old, No Replies

Firefox says: Error: document.forms[0].C1 is not a function

         

fototex

11:35 am on Apr 18, 2010 (gmt 0)

10+ Year Member



Hi developers,

I have a javascript function which lets a user to choose one of the 7 option buttons on a "mainsub.asp" page and the page will then be forwarded to one of the 7 process pages depending on what has been chosen.

The problem is that firefox is angry with the first line ("if" statement) and tells the following in its error console:

Error: document.forms[0].C1 is not a function
Source File: [localhost...]
Line: 117

Here is the code:

function fSubmit(){
if (document.forms[0].C1(0).checked) document.forms[0].action="process.asp";
else if (document.forms[0].C1(1).checked) document.forms[0].action="process1.asp";
else if (document.forms[0].C1(2).checked) document.forms[0].action="process2.asp";
else if (document.forms[0].C1(3).checked) document.forms[0].action="process3.asp";
else if (document.forms[0].C1(4).checked) document.forms[0].action="process4.asp";
else if (document.forms[0].C1(5).checked) document.forms[0].action="process5.asp";
else if (document.forms[0].C1(6).checked) document.forms[0].action="process6.asp";
else document.forms[0].action="process.asp";
return;
}

Internet explorer does not complain about anything and does its job great.
But I could not figure out how to change the code to be also compliant with Firefox?

Thanks for all the coments

fototex

7:39 pm on Apr 18, 2010 (gmt 0)

10+ Year Member



Hi folks,

This way it worked out:

function fSubmit(){
if (document.forms[0].C1[0].checked) document.forms[0].action="process.asp";
else if (document.forms[0].C1[1].checked) document.forms[0].action="process1.asp";
else if (document.forms[0].C1[2].checked) document.forms[0].action="process2.asp";
else if (document.forms[0].C1[3].checked) document.forms[0].action="process3.asp";
else if (document.forms[0].C1[4].checked) document.forms[0].action="process4.asp";
else if (document.forms[0].C1[5].checked) document.forms[0].action="process5.asp";
else if (document.forms[0].C1[6].checked) document.forms[0].action="process6.asp";
else document.forms[0].action="process.asp";
return;
}

Thank you for your support.

whoisgregg

4:36 pm on Apr 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad you got it sorted out fototex! :)