Display results of a calculation in an online form
Hello, after searching on the forum i paste this that is getting me nuts, lets start:
I have a online form that have 2 fields that i need to calculate and show it after clicking the calculate button.
The deal is that I have to use a Excel formula that the client need to be used.
Here is the excel formula I need to use (basically is a rule of thre, if G14 is biger than 0 then we divide in 81, but if is 0 theh we work with 66%):
=IF (G14>0,((J21/100)*100%/81%),((J21/100)*100%/66%))
Here is my script:
<script type="text/javascript">
function calculateTextfinal()
{
var op1=document.getElementById('e1');
var op2=document.getElementById('total1');
var result =document.getElementById('total2');
if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;
result.value=0;
result.value=parseInt(result.value);
result.value=parseInt(result.value)+(op1.value * op2.value /0.81);
}
</script>
I guess that the error is in my formula conversion and I need to make an IF the value of op1 (at excel G14) is a cero, any help could be great.
Last edited by ramonolea; May 28th, 2012 at 06:37 PM..
|