Hey Twey,
I still want to do this script in PHP but in the mean time can you tell me why the "discount" part of the script isn't working. I'm doing an "onFocus" in the discount field for the discount function. Originally I had the cleaning calculation and discount function together in one script but coulnd't get it to work that way either so I split it into 2 scripts, one for cleaning - which has always worked, and the other for discounts which has never worked. I renamed the discount function and changed the onFocus for that field to match but it still doesn't work. Here is the scripts the way they are now:
Code:
<SCRIPT language=JavaScript>
function Calculate()
{
// calculate total
if (charges.duration1.value < 7)
charges.cleaning.value = 110.01;
else
charges.cleaning.value = 0.00;
//charges.total.value = parseFloat(charges.rentalcost.value)
//+ parseFloat(charges.pheat.value) + (charges.cleaning.value) + (charges.SecurityDep.value) - (charges.discount.value) + (charges.tax.value);
}
</SCRIPT>
<SCRIPT language=JavaScript>
function Calc()
{
// calculate discount amount
if (charges.duration1.value > 27)
charges.discount.value = charges.rentalcost.value * .2;
else if (charges.duration1.value > 20 && < 28)
charges.discount.value = charges.rentalcost.value *.15;
else if (charges.duration1.value > 13 && < 21)
charges.discount.value = charges.rentalcost.value *.10;
else (charges.duration1.value > 6 && < 14)
charges.discount.value = charges.discount.value + 0.00;
//charges.discount.value = parseFloat(charges.discount.value)
//+ parseFloat(charges.pheat.value)
//+ parseFloat(charges.cleaning.value)
//+ parseFloat(charges.SecurityDep.value)
//- parseFloat(charges.discount.value)
//+ parseFloat(charges.tax.value);
}
</SCRIPT>
Here is the input field code:
Code:
<input onFocus=Calculate(); name="cleaning" type="text" class="inputnum" id="cleaning" size="5" maxlength="5" readonly />
Code:
<input onFocus="Calc();" name="discount" type="text" class="inputnum" id="discount" size="7" maxlength="7" readonly />
What part of this don't I understand? The "parseFloat" I commented out because I didn't need it.
Mark
Bookmarks