I have a webpage that uses some variables that take a few seconds to be calculated.
I want to create a text field where it can be shown the sum of those 2 variables, but the problem is that that text field has to delay a bit (1-2 seconds). I’ve tried with ” document.write(var1 + var2) ” inside the specific function, but when the sum is ready, the page dissapear and it shows me only the result ( I want the result to appear in the same page ). I’ve also tried with “setTimeout” and I’ve obtained the same result ( only the sum appears on a new page)
I can also use a button that makes the delay and works fine ( I know how to do that, but I dont know how to display it ), I want the result to appears on a text field on the same page, or as any text. I’ve seen buttons that converts itselfs into the result when pressed bue again I dont know how to do it
Can anyone help me please ?
Thank you !
if this is your text field.
insert value into it using this
similarly for inserting text in any text field add an id and insert using
getElementById