Good day!
This code is for autocalculate, and I got a problem when i want ot add the output of autocalculate in the value of textbox Amount.
here is the code:
[code=php]
<script type=”text/javascript” language=”javascript”>
function autocalearn(oText)
{
if (isNaN(oText.value)) //filter input
{
alert(‘Numbers only!’);
oText.value = ”;
}
var field, val, oForm = oText.form, TotEarn = a = 0;
for (a; a < arguments.length; ++a) //loop through text elements
{
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) //number?
{
TotEarn += val; //accumulate
}
}
//oForm.TotEarn.value = TotEarn.toFixed(2); //out
oForm.TotEarn.value = TotEarn.toFixed(2) + document.getElementById(‘Amount’).value;
}
</script>
the output of this code is when I input 10 and the amount data is 100 the total earn is 10100..its wrong..I want result is 110.