dotty
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by dotty
-
-
I do not get the input value x to add to i in the for loop. What am I doing wrong?
<!DOCTYPE html>
<html>
<body><input id="inp" type="number" > </input>
<button type="button" onclick=myFunction() > click</button>
<p id="result" > </p><script>
function myFunction(){
var txt= "";
res = document.getElementById("result");
res.innerHTML="";
var x= document.getElementById("inp").value;
var i= 0;
for ( ; i < 20; i++) {
txt += "input" + i + "<br>";
i = i += x ;
}
res.innerHTML=txt;
console.log(txt += "input is " + (i+x) + "<br>");
console.log(i);
}</script>
</body>
</html>
input value as an incremental number in a for loop
in JavaScript
Posted
Could you re write it for me? so I can see how it is done ? thank you !