1

I'm pass a order id with leading-zero to function, but in the function, the parameter alway convert to number without leading-zero,What should I do?

formatter:function(value, row, index) {
    return "<a href='javascript:listGoods("+'09100089'+")'><i class='fa fa-search-plus' /></a>";
                }

function listGoods(id) {
    jp.openViewDialog("goodInfo", "${ctx}/order/order/goods?id=" + id, "800px", "500px");
  }
2
  • Please provide some more information about what problem you are facing and what is your expected result . Commented Sep 11, 2019 at 6:59
  • Your question does not give enough information but may be following link solve your problem Why javascript parseInt ignoring leading zeros in the string? stackoverflow.com/questions/35238701/… Commented Sep 11, 2019 at 7:00

1 Answer 1

0

Your problem is you pass your parameter as a number not as a string. The solution looks like this:

formatter:function(value, row, index) {
    return "<a href='javascript:listGoods(`"+'09100089'+"`)'><i class='fa fa-search-plus' /></a>";
  }

function listGoods(id) {
    jp.openViewDialog("goodInfo", "${ctx}/order/order/goods?id=" + id, "800px", "500px");
  }

Here is another example:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>


<script>
    function addButton() {
        document.body.innerHTML = "<button onclick='showMeParameter(`" + "09100089" + "`)'>my button</button>";
    }

    function showMeParameter(id) {
        alert(id);
    }

    addButton();
</script>
</body>
</html>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.