Monday, September 12, 2011

Displaying a prompt box in JavaScript

By writing this code in your html file. It will display a prompt box, means there u would fill some information.


<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
  {
  document.write("Hello " + name + "! How are you today?");
  }
}
</script>
</head>
<body>


<input type="button" onclick="show_prompt()" value="Show prompt box" />


</body>
</html>

No comments:

Post a Comment