Function not defined by javascript

For some reason, my javascript code is messed up. When you start firebug, I get the error proceedToSecond not defined , but it is defined!

JavaScript:

 <script type = "text/javascript"> function proceedToSecond () { document.getElementById("div1").style.visibility="hidden"; document.getElementById("div2").style.visibility="visible"; } function reset_Form() { document.personalInfo.reset(); } function showList() { alert("hey"); if (document.getElementsById("favSports").style.visibility=="hidden") { document.getElementsById("favSports").style.visibility="visible"); } } //function showList2() { //} </script> 

HTML:

 <body> <!--various code --> <input type="button" onClick="proceedToSecond()" value="Proceed to second form"/> </body> 
+7
javascript html forms
source share
2 answers

Real problem with your

showList .

After the "visible" there is an additional ')' .

Remove this and it will work fine.

 function showList() { if (document.getElementById("favSports").style.visibility == "hidden") { // document.getElementById("favSports").style.visibility = "visible"); // your code document.getElementById("favSports").style.visibility = "visible"; // corrected code } } 
+18
source share

There are a few things to check:

  • In FireBug, see if there are loading errors that indicate that your script is poorly formatted and functions are not being logged.
  • You can also try entering " proceedToSecond " in the FireBug console to see if a function is defined.
  • One thing you can try is to remove the space around the @type attribute of the script tag: it should be <script type="text/javascript"> instead of <script type = "text/javascript">
+4
source share

All Articles