Core JavaScript

Displaying a Prompt

This JavaScript program demonstrates how to display a command prompt and receive the input.

DisplayingAPrompt.html

<!DOCTYPE html>
<html>
	<head>
		<title>XoaX.net's Javascript</title>
		<script type="text/javascript" src="DisplayingAPrompt.js"></script>
	</head>
	<body onload="Initialize()">
		<span id="idValue"></span>
	</body>
</html>

DisplayingAPrompt.js

function Initialize() {
	let sEntered = window.prompt("Enter your name!");
	let qSpan = document.getElementById("idValue");
	qSpan.innerHTML = "Your name is " + sEntered;
}
 

Output

 
 

© 2007–2025 XoaX.net LLC. All rights reserved.