ltdangkhoa Posted August 9, 2009 Share Posted August 9, 2009 i have 2 functions below, how can i keep the value of id not to be round figured function a(){var id = 5324940297598675569;alert(id); // here the result is 5324940297598676000b(id);}function b(id){alert(id); // here the result is 5324940297598676000, i want to transfer value to function b as 5324940297598675569 not 5324940297598676000} everyone, please help me! thanks alot and have a nice weekend Link to comment Share on other sites More sharing options...
Ingolme Posted August 9, 2009 Share Posted August 9, 2009 i have 2 functions below, how can i keep the value of id not to be round figuredfunction a(){var id = 5324940297598675569;alert(id); // here the result is 5324940297598676000b(id);}function b(id){alert(id); // here the result is 5324940297598676000, i want to transfer value to function b as 5324940297598675569 not 5324940297598676000} everyone, please help me! thanks alot and have a nice weekend Well, apparently Javascript's Number type only allows for 16 significant digits. 16 digits is a whole lot. If you're not going to do operations with these numbers, try making it a String instead. Link to comment Share on other sites More sharing options...
ltdangkhoa Posted August 10, 2009 Author Share Posted August 10, 2009 Thanks Ingolme! I've tried to use String but somethings happend... see below function a(){ var id = new String(); id = "5324940297598675569"; document.getElementById("a").innerHTML = '<a href="java script:b(' + id + ')">' + id + '</a>'; <-- when i use this method the result auto covert id to 5324940297598676000 // b(id); <-- but if when i use this one, the result is correct... but in my app, i don't want it load automatically like this }function b(id){ document.getElementById("b").innerHTML = id; } Link to comment Share on other sites More sharing options...
Ingolme Posted August 10, 2009 Share Posted August 10, 2009 Try putting quotes around the id value:document.getElementById("a").innerHTML = '<a href="java script:b(\'' + id + '\')">' + id + '</a>'; Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted August 10, 2009 Share Posted August 10, 2009 Try putting quotes around the id value:document.getElementById("a").innerHTML = '<a href="java script:b(\'' + id + '\')">' + id + '</a>'; Also, does it make sense to put a link in a link? (Setting the innerHTML of a link to the html of a link?)document.getElementById("a").href = "java script:b('"+id+"')>";document.getElementById("a").innerHTML = id; I also forgot how to use document.getElementById because I'm so used to jQuery Link to comment Share on other sites More sharing options...
ltdangkhoa Posted August 10, 2009 Author Share Posted August 10, 2009 everyone, thanks alot, i did it... new day coming up with me... Thanks thanks alot, not a spam post but i really want to thank your help! nice to everyone Link to comment Share on other sites More sharing options...
justsomeguy Posted August 10, 2009 Share Posted August 10, 2009 Firefoxrocks is right - that code creates infinitely nesting links. It's not valid to have a link inside another link. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.