Questions
Write a program using java script to accept a Name from user and display it.
Last Updated : 17 Jul 2025
Jan 24
Solution:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
Enter any String: <input type="text" id='name'><br>
<input type="button" value="Show" onclick="show()">
<script>
function show(){
var name =document.getElementById('name').value;
document.write("You Entered " + name);
}
</script>
</body>
</html>
OUTPUT:
Code Explanation:
- Input Field: Allows the user to enter a string.
- Button: When clicked, triggers the
show()
function. show()
Function: Retrieves the input value and displays "You Entered [input]" on the page.
Meanwhile you can watch this video
Watch Video