Jaws Posted October 4, 2012 Share Posted October 4, 2012 (edited) Kinda new to java and this website ofc.Been doing a few exercises and i am not sure why this is not working :(Help much appreciated Edit: forgot to add that i am trying to make the program check what number it is and then bring up a alert box with 1 of 2 outcomes body><canvas id="canvas1" width="640" height="480" ></canvas> <script type="text/javascript"> // turn the html5 canvas into something we can edit in javascript (call it myCanvas)... var myCanvas = (document.getElementById("canvas1")); // take a 2d context from the canvas (call it myContext)... var myContext = (myCanvas.getContext("2d")); // when we do drawing stuff, we do it to the context, not the canvas... myContext.strokeRect(0,0,640,480); myContext.fillText("hello", 20, 20); function myFunction() var n = 6; if (n <= 5) { alert ("Yes"); } else { alert ("NO"); } </script> <input type="button" onclick="myFunction()" value="Show alert box" /></body></html> Edited October 4, 2012 by Jaws Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2012 Share Posted October 4, 2012 The syntax to define the function is not correct, you're missing brackets around the body of the function. Link to comment Share on other sites More sharing options...
Jaws Posted October 4, 2012 Author Share Posted October 4, 2012 function (myFunction)() did you mean this? Link to comment Share on other sites More sharing options...
thescientist Posted October 4, 2012 Share Posted October 4, 2012 function (myFunction)() did you mean this? when in doubt, read the tutorials.http://www.w3schools.com/js/js_functions.asp and use your error console. Link to comment Share on other sites More sharing options...
Jaws Posted October 4, 2012 Author Share Posted October 4, 2012 Thanks for the help i got there in the end! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now