Friday, August 16, 2013

JavaScript prompt box

<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 a prompt box" />

</body>
</html>

Result


No comments: