+ 2

Web

How can I make the variable take the value of an input

3rd May 2020, 8:50 AM
RED x
RED x - avatar
16 Réponses
+ 3
This should do the work var tcr = document.getElementById('here').value ;
3rd May 2020, 10:42 PM
Mahmud Oyshik
Mahmud Oyshik - avatar
+ 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 :))
3rd May 2020, 9:02 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
3rd May 2020, 9:13 AM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
Use document.getElementById("input_id").value;
3rd May 2020, 8:51 AM
A͢J
A͢J - avatar
+ 1
Show your code.
3rd May 2020, 8:54 AM
A͢J
A͢J - avatar
+ 1
Null because you have to wait the window loading Make window.onload=function (){ //Your code here }
3rd May 2020, 8:58 AM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
Ok please wait
3rd May 2020, 9:02 AM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
Arb Rahim Badsa It works! Thank you That really helps!!
3rd May 2020, 9:05 AM
RED x
RED x - avatar
+ 1
Using jQuery let value=$("#input_field").val()
3rd May 2020, 8:33 PM
Tanishq Joshi
Tanishq Joshi - avatar
+ 1
var i = document.getElementById("here id of input).value; Most common and simple way to save value of an input in variable.
4th May 2020, 8:03 PM
Ashutosh
Ashutosh - avatar
0
Ya that gave me : null
3rd May 2020, 8:52 AM
RED x
RED x - avatar
0
Can you write it for me pls
3rd May 2020, 9:01 AM
RED x
RED x - avatar
0
var a = prompt("enter") ;
4th May 2020, 10:37 AM
mr sha
0
Use console.log(), it's key for understanding
12th Sep 2020, 3:24 PM
Max bax
Max bax - avatar
0
document. querySelector("").value
10th Feb 2021, 7:54 AM
Pranay Sehgal
Pranay Sehgal - avatar