hello i\'m very new to javascript so forgive me if the answer seems obvious...
this is my code which is executed at the click of a button in the body
fun
With innerHTML
code inside the for
loop you are always setting the value with the last time iterated value. Hence, you need to update your code to
for ( var x = A; x < B; x = x + D ) {
document.getElementById("q_box").innerHTML += x + "
";
}
OR
var y = "";
for ( var x = A; x < B; x = x + D ) {
y += x + "
";
}
document.getElementById("q_box").innerHTML = y;
I will recommend you to go for 2nd option, as it is better to set the updated value at once and not to extract the value and update for each iteration.