472,337 Members | 1,591 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

Function Not Defined Javascript Error in Firefox

I have an HTML form using JavaScript that seems to function properly in IE but not in Mozilla Firefox 1.5 or in Netscape 8.1 (based on Firefox). The error in Firefox/Netscape is "testForIt() not defined."

Following is the JavaScript code:

Expand|Select|Wrap|Line Numbers
  1. <script language="JScript">
  2.   <!--
  3.   var request = false;
  4.   var useImage = false;
  5.   var useFrame = false;
  6.   var inqnum, compname = 0;
  7.  
  8.   alert ('Java');
  9.  
  10.   if (document.images) useImage = true;
  11.   else if (navigator.appVersion.indexOf('MSIE 3') > -1) useFrame = true;
  12.  
  13.   function cleaninquirynumber(aValue)
  14.     {
  15.     var aResult = '';
  16.     var sValidChar = '0123456789';
  17.     for (n=0;n<=aValue.length;n++) {
  18.       if (sValidChar.indexOf(aValue.charAt(n)) != -1)
  19.         {
  20.         if (n == aValue.length - 4)
  21.         aResult = aResult.concat('-');
  22.         aResult = aResult.concat(aValue.charAt(n));
  23.         }
  24.       }
  25.     return(aResult);
  26.     }
  27.  
  28.   function cleancompanyname(aValue)
  29.     {
  30.     var aResult = '';
  31.     var sValidChar2 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  32.     aValue = aValue.toUpperCase();
  33.       bResult = 1;
  34.     for (n=0;(aResult.length<=(Math.min(aValue.length,4))) && bResult;n++) {
  35.       if (n > aValue.length) bResult = 0;
  36.       if (sValidChar2.indexOf( aValue.charAt(n)) != -1)
  37.         {
  38.         aResult = aResult.concat(aValue.charAt(n));
  39.         }
  40.       }
  41.     return(aResult);
  42.     }
  43.  
  44.   function testForIt() {
  45.       alert ('TestForIt.');
  46.       if ((document.getElementsByName('inqnum').value != '') && (document.getElementsByName('compname').value != '')) {
  47.       alert ('if Document');
  48.           if (useImage) {
  49.               request = true;
  50.               document.images["testImage"].src = cleaninquirynumber(document.getElementsByName('inqnum').value)+cleancompanyname(document.getElementsByName('compname').value) + '.gif';
  51.               alert ('if (useimage)');
  52.           }
  53.           else if (useFrame)
  54.               document.frames[0].location.href = 'e' + cleaninquirynumber(document.getElementsByName('inqnum').value)+cleancompanyname(document.getElementsByName('compname').value) + '.htm';
  55.           else {
  56.           alert ('Test-Load');
  57.               request = true;
  58.               loadIt();
  59.           }
  60.       }
  61.       return false;
  62.   }
  63.  
  64.   function loadIt() {
  65.       if (request)
  66.       {
  67.         document.logon.action = 'inq'+cleaninquirynumber(document.getElementsByName('inqnum').value)+cleancompanyname(document.getElementsByName('compname').value)+'.htm';
  68.         document.logon.submit();
  69.       }
  70.       request = false;
  71.  
  72.   }
  73.  
  74.   function failIt() {
  75.       request = false;
  76.       if (useImage)
  77.         {
  78.       document.images["testImage"].src = 'blank.gif';
  79.       }
  80.     document.logon.action = 'nocompanyinquiries.htm';
  81.     document.logon.submit();
  82.   }
  83.  
  84.  
  85.  
  86. if (useImage)
  87.     document.write('<IMG SRC="blank.gif" NAME="testImage" ALT="." WIDTH="1" HEIGHT="1" onLoad="loadIt()" onError="failIt()">');
  88. else if (useFrame)
  89.     document.write('<IFRAME FRAMEBORDER="0" WIDTH="1" HEIGHT="1" MARGINHEIGHT="0" MARGINWIDTH="0" SRC="blank.htm"><\/IFRAME>');
  90. //-->
  91. </script>
  92.  
  93.  
  94.  
And here is the HTML code that calls it:



Expand|Select|Wrap|Line Numbers
  1.     <FORM NAME="logon" action="nocompanyinquiries.htm"></FORM>
  2.     <table align=center><tr><td>Inquiry Number:</td><td><input type="text" name="inqnum" size="10" maxlength="10"></td></tr>
  3.     <tr><td>Company Name:</td><td><input type="text" name="compname" size="30"></td></tr>
  4.     <tr><td>&nbsp;</td><td><input type="submit" value="Go" onClick="testForIt()"></td></tr>
  5.     </table>
  6.  
Any ideas or suggestions would be greatly appreciated. Thank you all in advance.
Mar 16 '06 #1
6 67725
I have an HTML form using JavaScript that seems to function properly in IE but not in Mozilla Firefox 1.5 or in Netscape 8.1 (based on Firefox). The error in Firefox/Netscape is "testForIt() not defined."

Following is the JavaScript code:

Expand|Select|Wrap|Line Numbers
  1. <script language="JScript">
  2. <!--
  3. var request = false;
  4. var useImage = false;
  5. var useFrame = false;
  6. var inqnum, compname = 0;
  7.  
  8. alert ('Java');
  9.  
  10. if (document.images) useImage = true;
  11. else if (navigator.appVersion.indexOf('MSIE 3') > -1) useFrame = true;
  12.  
  13. function cleaninquirynumber(aValue)
  14. {
  15. var aResult = '';
  16. var sValidChar = '0123456789';
  17. for (n=0;n<=aValue.length;n++) {
  18. if (sValidChar.indexOf(aValue.charAt(n)) != -1)
  19. {
  20. if (n == aValue.length - 4)
  21. aResult = aResult.concat('-');
  22. aResult = aResult.concat(aValue.charAt(n));
  23. }
  24. }
  25. return(aResult);
  26. }
  27.  
  28. function cleancompanyname(aValue)
  29. {
  30. var aResult = '';
  31. var sValidChar2 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  32. aValue = aValue.toUpperCase();
  33. bResult = 1;
  34. for (n=0;(aResult.length<=(Math.min(aValue.length,4))) && bResult;n++) {
  35. if (n > aValue.length) bResult = 0;
  36. if (sValidChar2.indexOf( aValue.charAt(n)) != -1)
  37. {
  38. aResult = aResult.concat(aValue.charAt(n));
  39. }
  40. }
  41. return(aResult);
  42. }
  43.  
  44. function testForIt() {
  45. alert ('TestForIt.');
  46. if ((document.getElementsByName('inqnum').value != '') && (document.getElementsByName('compname').value != '')) {
  47. alert ('if Document');
  48. if (useImage) {
  49. request = true;
  50. document.images["testImage"].src = cleaninquirynumber(document.getElementsByName('inq num').value)+cleancompanyname(document.getElements ByName('compname').value) + '.gif';
  51. alert ('if (useimage)');
  52. }
  53. else if (useFrame)
  54. document.frames[0].location.href = 'e' + cleaninquirynumber(document.getElementsByName('inq num').value)+cleancompanyname(document.getElements ByName('compname').value) + '.htm';
  55. else {
  56. alert ('Test-Load');
  57. request = true;
  58. loadIt();
  59. }
  60. }
  61. return false;
  62. }
  63.  
  64. function loadIt() {
  65. if (request)
  66. {
  67. document.logon.action = 'inq'+cleaninquirynumber(document.getElementsByNam e('inqnum').value)+cleancompanyname(document.getEl ementsByName('compname').value)+'.htm';
  68. document.logon.submit();
  69. }
  70. request = false;
  71.  
  72. }
  73.  
  74. function failIt() {
  75. request = false;
  76. if (useImage)
  77. {
  78. document.images["testImage"].src = 'blank.gif';
  79. }
  80. document.logon.action = 'nocompanyinquiries.htm';
  81. document.logon.submit();
  82. }
  83.  
  84.  
  85.  
  86. if (useImage)
  87. document.write('<IMG SRC="blank.gif" NAME="testImage" ALT="." WIDTH="1" HEIGHT="1" onLoad="loadIt()" onError="failIt()">');
  88. else if (useFrame)
  89. document.write('<IFRAME FRAMEBORDER="0" WIDTH="1" HEIGHT="1" MARGINHEIGHT="0" MARGINWIDTH="0" SRC="blank.htm"><\/IFRAME>');
  90. //-->
  91. </script>
  92.  

And here is the HTML code that calls it:



Expand|Select|Wrap|Line Numbers
  1. <FORM NAME="logon" action="nocompanyinquiries.htm"></FORM>
  2. <table align=center><tr><td>Inquiry Number:</td><td><input type="text" name="inqnum" size="10" maxlength="10"></td></tr>
  3. <tr><td>Company Name:</td><td><input type="text" name="compname" size="30"></td></tr>
  4. <tr><td>&nbsp;</td><td><input type="submit" value="Go" onClick="testForIt()"></td></tr>
  5. </table>

Any ideas or suggestions would be greatly appreciated. Thank you all in advance.
Mar 16 '06 #2
Incidentally the alerts were just something I there in for testing purposes.
Mar 16 '06 #3
Nevermind, I think I found it. I inherited the code and just noticed that the original programmer had specified JScript rather than Javascript as the script language.
Mar 16 '06 #4
acoder
16,027 Expert Mod 8TB
Yes, that would cause problems. In fact, the language attribute is deprecated and should be replaced with the type attribute:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
Jun 21 '08 #5
Using FF I just stumbled upon the 'JavaScript' versus 'text/javascript' error for a JS script that wasn't loading. Keep in mind that all the other 20+ scripts for the site had 'JavaScript' for the type, but the latest one I created would not load until I made it's type = 'text/javascript'.

Can someone say GAY?!?!?!
Feb 6 '10 #6
acoder
16,027 Expert Mod 8TB
Was that type or language?

If you're going to use non-standard or deprecated attributes, expect things not to work.
Feb 7 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Corey | last post by:
I recently received a Javascript error, "'WebForm_PostBackOptions' is undefined" from an application I'm working on. It occurs during the PostBack...
1
by: questionr | last post by:
There is a spell checker function which is written in VB Script. The function works well when tested seperately. But when the function is called...
6
by: Richard Silverstein | last post by:
I'm a member of a forum sponsored by jasc.com ( http://forums.jasc.com/ ) which uses Webboard software. I use Firefox 1.0 (final release) as my...
18
by: William | last post by:
I have the following javascript function that updates a scroll_list and sends the updated entry (with its index) to a server script ( i.e....
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something...
1
by: prash.marne | last post by:
Hi, I am trying open a simple popup window & my code is .. <html> <head> <title>popup_window</title> <script type="text/javascript">...
1
by: nitinp | last post by:
hello, I am trying to validate empty textbox value by javascript in Firefox. It is working fine in IE but not in Firefox. Note - code is for...
3
by: markus.rietzler | last post by:
i want to do (multiple) file upload(s) and display a progress bar. with firefox and safari it is no problem at all. only IE makes some problems. ...
2
by: ShinKaiser | last post by:
Hi there, I use a Javascript lightbox application known as lightwindow on my site, basically I have set up lightwindow to launch from flash via the...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.