0
change value of input
i'm trying to change the value of input element with javascript and i did it( based on console.log )but Input value doesn't display correct in html , any idea? <h4 style="color: red; "> System is rebooting now ... <br/><br/>Please Wait <input type="text" name="n" value="30" style=" width: 30px ; height: 15px; " > s <script type="text/javascript"> for (var i =29 ; i >=0; i--) { document.getElementsByTagName('n').value=i; console.log(document.getElementsByTagName('n').value=i , i ); } </script> </h4> </code>
2 Respostas
+ 1
no i wanted in this way obviously i did except a sleep function and not all await...
the other thing that i learnd is name and elementsbytagname not related its for input
even in that case its notworking and i have to use id for this =))
after 2 years =)
https://code.sololearn.com/WKEUMfqz77rU/?ref=app
+ 9
<!-- i believe you wanted this... -->
<h4 style="color: red; "> System is rebooting now ...
<br/><br/>
Please Wait
<span id="n" value="30" style="width: 30px ; height: 15px; " >30</span> s
</h4>
<script>
var i = 30,
int = setInterval(function timed() {
document.getElementById('n').innerHTML = i;
if (!i--) {
clearInterval(int);
document.getElementById('n').innerHTML = "{ERROR! try again... :P}";
}
//console.log(document.getElementsByTagName('n').innerHTML, i);
}, 1000 /* change every 1 second */);
</script> <!-- after H4 !! -->