+ 3
How to get input from the users in javascript programming language
I want to get the data using forms in html
3 Réponses
+ 9
var person = prompt("Please enter your name", "Harry Potter");
if (person != null) {
document.getElementById("demo").innerHTML =
"Hello " + person + "! How are you today?";
}
like that...
https://www.w3schools.com/jsref/met_win_prompt.asp
https://www.w3schools.com/js/js_input_examples.asp
+ 3
Example:
<input type="text" class="input_class">
<button class="btn" onClick="getValue()"><button>
Javascript:
function getValue(){
var inputVal = document.querySelector(".input_class").value
alert(inputVal)
}
+ 2
<form name="f" onsubmit="alert(f[0].value); event.preventDefault();">
<input type="text" />
<button type="submit">Send</button>
</form>
https://code.sololearn.com/WHW6Acl3iWcY/?ref=app