My webpage has some variables that take a few seconds to calculate. I want to display the sum of these two variables in a text field, but it needs to have a slight delay (1-2 seconds). I tried using "document.write(var1 + var2)" inside a specific function, but the page disappears once the sum is ready and only shows the result (I want it to appear on the same page). I also attempted to use "setTimeout" with no success.
I could use a button to create the delay, which works fine, but I don't know how to display the result. I want the sum to be shown in a text field on the same page. I've seen buttons that convert into the result when pressed, but I'm not sure how to achieve this. Can anyone offer assistance? Thank you!