Hi i've researched evrywhere on how to call to function and i keep seeing that all i need is the following line but is not working well at least when i try on to run on w3school text editor http://www.w3schools.com/js/tryit.asp?filename=tryjs_function1 onClick="doFunction1(); doFunction2(); " Code (markup): this is how my whole code looks like why it only call the first function why?? <script type="text/javascript"> function doFunction1() { document.write("Hello World!"); } function doFunction2() { document.write("morning"); } </script> </head> <body> <form> <input type="button" value="Click me!" onClick="doFunction1(); doFunction2(); " /> </form> Code (markup):
onClick="doFunction3();" <script type="text/javascript"> function doFunction1() { document.write("Hello World!"); } function doFunction2() { document.write("morning"); } function doFunction3() { doFunction1(); doFunction2(); } </script>
this way working for you??? <script type="text/javascript"> function doFunction1() { document.write("Hello World!"); } function doFunction2() { document.write("morning"); } </script> </head> <body> <form> <input type="button" value="Click me!" onClick="doFunction1(); doFunction2(); " /> </form> Code (markup):
i'm using here http://www.w3schools.com/js/tryit.asp?filename=tryjs_function1 this online text editor for w3school just pate the code in there click edit and run you will notice it doesnt run
well it only runs the first function which write hello world but doesnt run the second function whic is meant to write morning
This works fine for me: <html> <head> <script type="text/javascript"> function displaymessage1() { alert("Hello World!"); } function displaymessage2() { alert("Hello again"); } </script> </head> <body> <form> <input type="button" value="Click me!" onclick="displaymessage1(); displaymessage2();" /> </form> <p>By pressing the button above, a function will be called. The function will alert a message.</p> </body> </html> Code (markup): If this doesn't for you tell us which browser you use, which version and whether you're sure you have JS enabled.
thansk yeah it is working now just one more thing if you can that i am trying to work i have this functions which load the video file onto the player <a title="Testimonial One" href="#" onClick="loadNplay({file="videos/film.mp4" hd.file="videos/film.mp4"});"><img src="images/24hrs.jpg" border="0" title="picture" /></a> Code (markup): can i also include the second function the same one as the one you gave me by adding the second funcion name after this function [displaymessage2();] so it would be like this? <a title="Testimonial One" href="#" onClick="loadNplay({file="videos/film.mp4" hd.file="videos/film.mp4"}); displaymessage2();" /><img src="images/24hrs.jpg" border="0" title="picture" /></a> Code (markup): do you think that will work?