[thelist] javascript comparison
Rob Smith
rob.smith at THERMON.com
Wed Oct 29 13:58:43 CST 2003
>> Is there a way I can cast values in javascript?
>not really, but you can ...
do Number(bid.nextbid.value) or String(bid.nextbid.value) it works.
Now "they" want you to bid at least $.25 more than the previous bid. So with
my new casting I have:
if (Number(bid.previousbid.value) > Number(bid.nextbid.value-.25)) {
alert("Please enter a bid greater than $" +
(Number(bid.previousbid.value)+.24) + ".");
}
Sample Test:
=============
Previous bid: $ 16.02
Minimum bid: $ 16.26
Error Message:
==============
Please enter a bid greater than $16.259999999999998.
What!??!! Where did all those 9's come from?! I tried adding the round()
function around the (Number(bid....)) and it broke the sequence; the test
failed.
Rob.Smith
More information about the thelist
mailing list