0
i want to feed my javascript var value = value filled in an <input> . can i do it ? if yes please suggest the code.
i want to pass input value through loops. <input type="text" id="main"> <script> var value = document.getElementById("demo") ; if(value.length <= 6){ document.write("hellow world"); } </script>
3 Answers
+ 2
Practically nobody would use document.write to update any dom element. Please don't use document.write in your web update.
You can update input by
document.getElementById("demo").value = "hello world");
+ 1
In the if section you can write,
if(value.length<=6){
value.innerHTML="hello world"
}
this will assign the element with id demo "hello value"
or you can do what Calvin says
0
ok!!
but i don,t want to print hellow world in main id .i want to pass input box value in if statement.
like if input box value's length is less or equal to 6 let say alert(" sjdvdjdjd" )
now how can i assign the var value /* in if operator */ = value filled in input box with id main