| Display a prompt box which ask the user for her/his name, and output a message: |
|
Example 1
Example 1a
Note: JavaScript does not have native (built in) input or output routines. Instead it relies on the facilities provided by its host environment (e.g.web browser).
|
The html looks like this
<!DOCTYPE html>
<html>
<body>
<p>Click the button to demonstrate the prompt box.</p>
<button onclick="myFunction()">Start</button>
<p id="demo"></p>
<script language="JavaScript">
function myFunction() {
var person = prompt("Please enter your name", "");
if (person != null) {
document.getElementById("demo").innerHTML =
"Hello " + person;
}
}
</script>
</body>
</html>
|
|
See: See Example 1b Javascript Window prompt() Method | w3schools.com dom - JavaScript get input text value - Stack Overflow Javascript | |