Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written the following code in Javascript to show alert box when user clicks on "Submit" button but alert box is not appearing on clicking submit button:

XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> Javascipt Tag Position</title>
  <script type="text/javascript" language="javascript">
  funciton hello()
  {
    alert("Script inside head tag!");
  }
  </script>
 </head>

 <body>
    <input type="submit" name="sub" value="Submit" onclick="hello()">
 </body>
</html>


Note: I have saved this file as "js1.php" since i am learning php as well.
Posted
Comments
Afzaal Ahmad Zeeshan 24-Aug-15 11:01am    
What is the problem? See the console for more, does the page reload?

You've misspelled "function" as "funciton"
 
Share this answer
 
Comments
Thomas Daniels 24-Aug-15 11:12am    
Yup, +5! I was about to post the same, but you beat me. :P
Member 11930850 24-Aug-15 13:51pm    
Thanks Dear! You got the problem. Now it's working
Use below code:




function hello()
{
alert("Script inside head tag1!");
return false;
}



This will work..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900