0
Alert with HTML Element
How can I create an Alert Writing Hello+username (Input with id="username" from HTML)
4 odpowiedzi
+ 3
You need to handle some interactivity, by adding at least a button ( or a link, or something else ) to validate user entry ( and showing the alert box ), as you can't automatize the opening of the box ( where, when, and how? ):
<input id="username" type="text">
<input type="button" value="ok" onclick="alert('Hello '+document.getElementById('username').value);">
+ 2
write some username in text field
0
var user=document.getElementById('username').value;
alert("Hello " + user);
0
okay, what should i do in the HTML document to define the .value ?