Skip to content Skip to sidebar Skip to footer

How To Update Javascript Variable Value In Html Without A Page Refresh

I am collecting a text area value(number in decimal ) using its id to a javascript variable, adding another variable value (number in decimal), and displaying the result in same ht

Solution 1:

If it's going to update whenever you type into the input, you need an event handler:

document.getElementById('num').onkeyup = function() {
    var a = 1000 + parseFloat(this.value);
    document.getElementById("test").innerHTML = a || 0;
}

FIDDLE

Post a Comment for "How To Update Javascript Variable Value In Html Without A Page Refresh"