Web | SoloLearn: Learn to code for FREE!

+2

Web

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

5/3/2020 8:50:44 AM

RED x

15 Answers

New Answer

+3

This should do the work var tcr = document.getElementById('here').value ;

+2

Null because you have to wait the window loading Make window.onload=function (){ //Your code here }

+2

https://code.sololearn.com/WelqdkOA0z48/?ref=app

+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

+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