<GT*******@disc ussions.microso ft.comwriting in
news:44******** *************** ***********@mic rosoft.com:
ASP has no knowledge of the client, this is a client side issue.
Followups set to comp.lang.javas cript.
Hi All,0,widt
I have a neat little script that calculates price based on quantity
without refreshing the page.. the script is -
<script type="text/javascript">
function OpenWin(url)
{
window.open(url ,'win','scrollb ars=1,status=0, resizable=
h=200,height=26 5');
}
function btnCalculate_on click()
{
var numQty;
var adprice;
if (isNaN(document .frmClient.txtQ ty.value))
{
alert('Please enter a number for advert quantity.');
}
else
{
numQty = parseInt(docume nt.frmClient.tx tQty.value);
adprice = parseInt(docume nt.frmClient.ad price.value);
if((numQty >= 1) && (numQty <= 1)){
document.getEle mentById('divPr ice').innerHTML = '£' + adprice + '
+ VAT'; document.getEle mentById('maind ivPrice').inner HTML = '£' +
Math.round(100* (adprice * numQty))/100 + ' + VAT';
} else if((numQty >= 2) && (numQty <= 10)){
document.getEle mentById('divPr ice').innerHTML = '£' +
(Math.round(adp rice * numQty)*.95)/numQty + ' + VAT';
document.getEle mentById('maind ivPrice').inner HTML = '£' +
Math.round(adpr ice * numQty)*.95 + ' + VAT';
} else if((numQty >= 11) && (numQty <= 20)){
document.getEle mentById('divPr ice').innerHTML = '£' +
(Math.round(adp rice * numQty)*.85)/numQty + ' + VAT';
document.getEle mentById('maind ivPrice').inner HTML = '£' +
Math.round(adpr ice * numQty)*.85 + ' + VAT';
} else if((numQty >= 21) && (numQty <= 30)){
document.getEle mentById('divPr ice').innerHTML = '£' +
(Math.round(adp rice * numQty)*.75)/numQty + ' + VAT';
document.getEle mentById('maind ivPrice').inner HTML = '£' +
Math.round(adpr ice * numQty)*.75 + ' + VAT';
} else if((numQty >= 31) && (numQty <= 50)){
document.getEle mentById('divPr ice').innerHTML = '£' +
(Math.round(adp rice * numQty)*.5)/numQty + ' + VAT';
document.getEle mentById('maind ivPrice').inner HTML = '£' +
Math.round(adpr ice * numQty)*.5 + ' + VAT';
} else {
alert("Please contact us for more information about the benefits
of our
monthly account packages.");
}
}
}</script>
The problem I have is that it doesn't round up, for instance in stead
of £0.95 i get £0.94999999999 98.
Does anyone have any ideas how to fix this?
Many thanks
--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share