“Javascript made me feel like a IDIOT”
July 2, 2008
Today I was doing some javascript checks so that my regular price remains
always greater than the discounted price .
I check with normal arithmetic functions “==,<,>” to the $(“field_name”).value
and thought it has worked because that what was taught to me in my schools
that value 1 > value 2 returns true/false.
But all my prettiest school teachers were proven wrong by javascript.
I realized after releasing the code that
11> 10 => true
99.99 > 99.98 => true
212 > 212.21 => false
but they were also checking the number of digits.
So when I gave
10 > 9 => false(It failed) …hmm even I had the same reaction!!!!
Man , what the S**T cum on how can this happen , then I thought
bro need to check javascripts arithmetic handlers once again ,
over there I came accross parseFloat and other functions.
check the link for more details
For the next two days I shall be wearing the “I was wrong ” Tshirt….
Technorati Tags: rails, ruby on rails, ror, ruby, javascript, parseFloat to check the arithemetic methods properly, comparing numbers in javascriptrails, ruby on rails, ror, ruby, javascript, parseFloat to check the arithemetic methods properly, comparing numbers in javascript
Entry Filed under: Ruby, comparing numbers in javascript, javascript, parseFloat to check the arithemetic methods properly, rails, ror, ruby on rails. Tags: comparing numbers in javascript, javascript, parseFloat to check the arithemetic methods properly, rails, ror, Ruby, ruby on rails.
1 Comment Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed
1.
Piyush Gupta | July 2, 2008 at 12:55 pm
Thanx Santhiya