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>

11th May 2020, 4:15 AM
Divya Mohan
Divya Mohan - avatar
3 Respuestas
+ 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");
11th May 2020, 4:30 AM
Calviղ
Calviղ - avatar
+ 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
11th May 2020, 6:29 AM
Yash Jain
Yash Jain - avatar
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
11th May 2020, 5:44 AM
Divya Mohan
Divya Mohan - avatar