Hi,
I have an html file that accepts user inputs then uses Javascript to calculate a value based on those inputs. That result is then displayed in an input box after the program has finished.
What I'd like to do is make it so that when you click on the button to run the javascript, the input box that displays the result will show 'Calculating...' until the calculation finishes (the calculation can take ~5 seconds). However, if I put something like:
document.getElementById('answer').value = 'Calculating...';
at the very top of my Javascript code, it doesn't seem to update the input field whenever it runs. Instead, the program runs and then the result is finally updated in the input field.
Anyone know how I can update the input field when I run the program, then update it again with the result once the program finishes?
Thanks!
EDIT: Here's a better explanation of my code
<td colspan=1 align=left><input id="button" value="Calculate" onclick=calculate(this.form.type.value,this.form.d.value,this.form.c.value,this.form.freq.value)>
<input id="answer" readonly="true">
</td>
</tr>
function calculate(type,d,c,f) {
//Performs some calculation
document.getElementById('answer').value = TS;
}