Sponsored Ad

Thursday, April 22, 2010

How to Take Input From User in JavaScript

Taking a input from user is very important feature in any language. It makes a bridge between user and computer. So JavaScript also have this feature and can be implemented by prompt() method.

 

var identity= prompt("Please enter your identity","")

 

This Sample JavaScript code will help you to receive input from user and display it in webpage. prompt function is used here to take a value from user and store it in a variable. Again this program displays the value of variable.

 

<html>
<head>
</head>
<body>
<script type="text/javascript">
var identity= prompt("Please enter your identity","")
if (identity!= null && identity!= "")
{ document.write("Hey  " + identity) }
</script>
</body>
</html>

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers