hi..let's say I have 3 textfields, texfield A must be filled first, then textfield B and textfield C can be filled either one. If textfield B is filled, then for example (textfield A * textfield B), the answer will be shown at textfield C or vice versa.
Below is part of my code.
<script type="text/javascript">
function calculate()
{
if(form.textfieldC.value != "")
{
var p_Deposit = document.getElementById("textfieldB").value = ((document.form.textfieldC.value / document.form.textfieldA.value) * 100);
}
else if(form.textfieldB.value != "")
{
var a_Deposit = document.getElementById("textfieldC").value = (document.form.textfieldA.value * (document.form.textfieldB.value/100));
}
}
</script>
<td><input type="text" name="e_percent" id="e_percent" onKeyUp="calculate()"><span class="font"> (%)</span></td>
<td><input type="text" name="e_amount" id="e_amount" onKeyUp="calculate()"></td>
This doesn't work because since the textfield A is filled out first, then the rest two textfields is empty, the javascript will detect they are in empty state, so it directly read the else statement. Is anybody know the solution to solve this problem? Thanks in advance.