lundi 8 mars 2021

Prevent truncating of preceeding zeros in Javascript

I am trying to pass variable to a JavaScript function that then makes an Ajax request using the variable. My problem is that if the value of the variable starts with zeros, the zeros are truncated. For example, if the value is 00056, what is sent for an Ajax call is 56

Here is what I am doing

 <a class="btn" onclick="return callFxn(<?php echo  $var; ?>);" href="" >Click here</a>

How do I adjust this function so that the zeros are not truncated. I guess the variable needs to be sent as a string. I can't figure out how to do this.

function callFxn(output) {
    alert(output) //value is truncated here
 }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3t5zfwb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire