Two functions called by a nav link will not execute. They are declared in the <head> area. painting.php - main file nav_paintings - nav file include Thank you v. much for any guidance. Here is the code for the functions and variable declarations, declared in the <head>: <script type="text/javascript"> var count; var imageURL; </script> <script type="text/javascript"> function directionBack() { if (count > 1) count = count - 1; return count; } </script> <script type="text/javascript"> function imageToDiv(count) { imageURL = "<img src=\'images/painting_\' + count + \'.jpg' />"; document.getElementById("imagediv").innerHTML = imageURL return false; } </script> Code (markup):
Functions are executing, no errors. I corrected the onBlur code, too. It looks like either count is not being decremented in directionBack() or imageToDiv is not replacing the html. These are the functions as they stand now. <script type="text/javascript"> function directionBack() {if (count > 1){ count = count - 1; return count; }} </script> <script type="text/javascript"> function imageToDiv(count) { var imageURL = '<img src="images/painting_' + count + '.jpg" />'; document.getElementById("imagediv").innerHTML = imageURL; return true; } </script> Code (markup):
Open your page in Google Chrome browser, then go to menu Tools->Developer Tools. This will open up a console which is useful for debugging javascript stuff. It can tell you if you have a syntax error. You can place a break point in the javascript code so you can step thru the code.
Hey, jkl6, thank you! I've been using Firebug, but it really doesn't handle js debugging all that well.
check the quotes: <script type="text/javascript"> var count; var imageURL; </script> <script type="text/javascript"> function directionBack() { if (count > 1) count = count - 1; return count; } </script> <script type="text/javascript"> function imageToDiv(count) { imageURL = "<img src=\'images/painting_\'" + count + "\'.jpg' />"; document.getElementById("imagediv").innerHTML = imageURL; return false; } </script> Code (markup):