Write a java script program to accept the user name and display it on the browser
The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Ask Questions
Hey! Want to work with us? Our youtube channel See our Jd Want to apply? Do it today

Use Me  ?

New searches
Programming-the-Web10CS73-unit-3-->View question


Write a java script program to accept the user name and display it on the browser?

A very simple java script program to accept the user name and display it on the browser when it is loaded.

By:edu-Freak

Taged users:


Likes:
Be first to like this question

Dislikes:
Be first to dislike this question

Talk about thisDelete|Like|Dislike|


Answers

<!DOCTYPE html>
<html>
<body>

<p>Click the button to demonstrate the prompt box.</p>

<button onclick="userName()">Try it</button>

<p id="demo"></p>

<script>
function userName() {
    var person = prompt("Please enter your name", "Tom dick or harry");
    
    if (person != null) {
        document.getElementById("demo").innerHTML =
        "Hello " + person + "! This is your user name?";
    }
}
</script>

</body>
</html>

edu-Freak

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this|Once you have earned teacher badge you can edit this questionDelete|Like|Dislike|
------------------------------------
The above mentioned code will pop up a window when it is got submitted and it will alert the user with its username.
edu-Freak

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this|Once you have earned teacher badge you can edit this questionDelete|Like|Dislike|
------------------------------------

Can you help us to add better answer here? Please see this



Not the answer you're looking for? Browse other questions from this Question paper or ask your own question.

Join eduladder!