+ 1
How to transfer the value of input to the variable js
I'm just starting to learn the course of js through SoloLearn and having reached logical operations I wanted to write a simple program that compares the value of <input> with the value of the variable js. I will be very grateful for the answer!)
3 Réponses
+ 5
<input type='text' id='demo' value="Hello Guy!" />
<script>
var inputData = document.getElementById("demo").value;
alert(inputData);
</script>
+ 2
You can get the value of an input using this:
var whatYouWant = document.getElementById("...").value
where ... is the id of input element.
So the rest is:
if(whatYouWant == otherVar) {...}
+ 1
var variable = document.write[form][name].value;