0

I am calling showedit function with argument. But when i alert it in the function it is showing partial value.

Here is the HTML code:

<a href="javascript:void(0)" onclick="showedit(856478546521458789);">
    <i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 20px;float: right;"></i>
</a>

Here is the Javascript code:

function showedit(id) {
    alert(id);
    document.getElementById("update_status_" + id).style.display = "block";
    document.getElementById("status_" + id).style.display = "none";
}

Can you tell me what is the problem?

Mahbubul Islam
  • 998
  • 1
  • 10
  • 24
  • 2
    Possible duplicate of [What is JavaScript's highest integer value that a Number can go to without losing precision?](https://stackoverflow.com/questions/307179/what-is-javascripts-highest-integer-value-that-a-number-can-go-to-without-losin) – ADreNaLiNe-DJ Jul 28 '17 at 12:31
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER – Teemu Jul 28 '17 at 12:31
  • Maybe you should write it as a string instead of a number. – Stephan Jul 28 '17 at 12:32
  • Did you try to pass the number as a string? It does not look like the number is used in any math – Huangism Jul 28 '17 at 12:32

1 Answers1

1

Send the argument as a string. See the code snippet below:

<a href="javascript:void(0)" onclick="showedit('856478546521458789');">
    <i class="fa fa-pencil-square-o" aria-hidden="true" style="font-size: 20px;float: right;"></i>
</a>

It is happening because it is exceeding JavaScript's MAX_INT value.

chazsolo
  • 7,873
  • 1
  • 20
  • 44
Mahidul Islam
  • 580
  • 11
  • 29