0
How to assign a value from <input> to a variable? JS
How to assign y a value from < input >? Html <input type="text" id="answer"> <button onClick="verifyText" >Verify</button> JS function verifyText () { var x = "It is a text" ; If (x == y) { alert('hello world') } } How can i do y as a text from input How to assign y a value from the input
19 Réponses
+ 1
like you want the input as int ?
+ 1
<input type="number"
+ 1
For example, I entered the text "it is a text"
And
I need to compare this text with the variable x
+ 1
line 6, if
not If
0
y = document.getElementById("answer).value
0
And if i have a text there?
0
It's not a value
0
Yes
0
ooooooh
use my first example. then
if(x==y)
0
What's wrong?
0
you have a typo in line 6. if should be lowercase
0
I entered a text "It is a text" and nothing happened
0
Oh yeah
0
And now
0
line 9 in html
you need () to call the function
verifyText()
0
Oh yeah
0
Thank you very much
0
sure