“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: , , , , , , , , , , , ,

Entry Filed under: Ruby, comparing numbers in javascript, javascript, parseFloat to check the arithemetic methods properly, rails, ror, ruby on rails. Tags: , , , , , , .

1 Comment Add your own

  • 1. Piyush Gupta  |  July 2, 2008 at 12:55 pm

    Thanx Santhiya

Leave a Comment

Required

Required, hidden

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


Recent Posts

Tags

Active Record australian gp calendar date select capistrano capitalize debugging Debugging in rails edge rails formula 1 For those who dont want to update the prototype.js fun Fun baby fun google html in join javascript linus vs windows compatibility linux logging love song malaysian gp 2008 results melbourne migrations music mysql plugin poetry rails regexp regular expression results formula 1 opening race romantic poetry ror Ruby ruby on rails safe html sms song SQL string case handler for strings syantax syntax error for migrations on linux Text Area they can checkout 1.8.3 of the calender date select

Blogroll

Pages