PDA

View Full Version : Math help (very easy)


Local Hero
04-30-2005, 01:49 AM
I'm sorry, but I've read the books and I can't figure out JavaScript. So my problem is simple. I have a site where I've made this code:

<script language="JavaScript">
<!--
function screen() {
if ((document.orderform_16180.amount.value == null || document.orderform_16180.amount.value.length == 0))
{ document.orderform_16180.price.value = "Incomplete data";
}
else
{
var quant = document.orderform_16180.amount.value;
document.orderform_16180.price.value = Math.round(((100/ ( Math.sqrt(25 * quant)))+3)*100)/100 ;
}


}

// -->
</script>

But the math (100/sqrt(25*quant))+3 is not what I want. I want it to be this:

If (quantity) 1<or=x<or=20 then y (price)=.0524x^2+-2.1391x+32.04575
If (quantity) 20<x<or=50 then y (price)=39.779 * x^-.4532
If (quantity) 50<x<or=7715 then y (price)=10.4835 * x^-.121635
If (quantity) 7715<x then y (price)=4

I know this is simple, but I don't get it.