+ 2
Web
How can I make the variable take the value of an input
16 Respostas
+ 3
This should do the work
var tcr = document.getElementById('here').value ;
+ 2
RED x You are almost correct, just a bit mistake you did there!
Correction :
var a = document.getElementById('here').value;
You've to write the id in Between the quotation mark :))
+ 2
https://code.sololearn.com/WYlhkXS1RBQ0/?ref=app
Another example
+ 1
Use document.getElementById("input_id").value;
+ 1
Show your code.
+ 1
Null because you have to wait the window loading
Make
window.onload=function (){
//Your code here
}
+ 1
Ok please wait
+ 1
Arb Rahim Badsa
It works!
Thank you
That really helps!!
+ 1
Using jQuery
let value=$("#input_field").val()
+ 1
var i = document.getElementById("here id of input).value;
Most common and simple way to save value of an input in variable.
0
Ya that gave me :
null
0
Can you write it for me pls
0
var a = prompt("enter") ;
0
Use console.log(), it's key for understanding
0
document. querySelector("").value