user
0
Q:

input in javascript

// how to take input in javascript from user
Copyvar name = window.prompt("Enter your name: ");
alert("Your name is " + name);
4
var answer = prompt("Ask your question here");
1
var input = prompt("Enter input:");
0
Copyvar name = window.prompt("Enter your name: ");
alert("Your name is " + name);
-1
<html>
<head>
<title>Form Example</title>
<script LANGUAGE="JavaScript" type="text/javascript">
function display() {
  DispWin = window.open('','NewWin', 'toolbar=no,status=no,width=300,height=200')
  message = "<ul><li><b>NAME: </b>" + document.form1.yourname.value;
  message += "<li><b>ADDRESS: </b>" + document.form1.address.value;
  message += "<li><b>PHONE: </b>" + document.form1.phone.value + "</ul>";
  DispWin.document.write(message);
}
</script>
</head>
<body>
<h1>Form Example</h1>
Enter the following information. When you press the Display button,
the data you entered will be displayed in a pop-up window.
<form name="form1">
<p><b>Name:</b> <input TYPE="TEXT" SIZE="20" NAME="yourname">
</p>
<p><b>Address:</b> <input TYPE="TEXT" SIZE="30" NAME="address">
</p>
<p><b>Phone: </b> <input TYPE="TEXT" SIZE="15" NAME="phone">
</p>
<p><input TYPE="BUTTON" VALUE="Display" onClick="display();"></p>
</form>
</body>
</html>
0
Input Text Object
The Input Text object represents an HTML <input> element with type="text".

Access an Input Text Object
You can access an <input> element with type="text" by using getElementById():

Example
var x = document.getElementById("myText");
Tip: You can also access <input type="text"> by searching through the elements collection of a form.

Create an Input Text Object
You can create an <input> element with type="text" by using the document.createElement() method:

Example
var x = document.createElement("INPUT");
x.setAttribute("type", "text");
2

New to Communities?

Join the community