user3100198
user3100198

Reputation: 35

How to solve error in passing the value to javascript function?

I have a function

function del(str)
{
    alert(str);
}

and i have some ahref links for passing value in above javascript function like these

 1. <a href="javascript: del(13121110581541114);">Click</a>


 2. <a href="javascript: del(13121110581541118);">Click</a>


 3. <a href="javascript: del(13121110581541039);">Click</a>


 4. <a href="javascript: del(13121110581541117);">Click</a>

But problem if i click on link which have Even number for passing then alert show right digit, but when i click on link which have Odd number for passing then alert show (passing number + 1) digit

for E.g on click 1st ahref alert show 13121110581541114

while on click 3rd ahref alert show 13121110581541040

i don't know what's problem, plz help me

Upvotes: 2

Views: 61

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382167

This number can't be represented in the JavaScript number format (which is the IEEE754 double format) : 13121110581541039

You need to change the design of your application : use strings for example, or make it so you deal only with integers whose absolute value is smaller than 2^53.

Upvotes: 5

Related Questions