Send a string in javascript

0

Is there a way to send a string by parameters in javascript ?

I have something like:

<i class="fa fa-folder-open" aria-hidden="true" style="cursor:pointer;" onclick="en('.$datas['contribuinte'].')"></i> 

This button when clicking has to take the variable to the function, but sometimes the variable inside can contain zeros on the left, so the function recognizes as integer and removes the zeros, so I want to turn it into a string.

Function:

    function en(x)
{
    window.open("en/vers.php?cls="+x,"_blank");
}

Example: If the variable contains "000000001" I did not want the function to be "1".

    
asked by anonymous 07.06.2016 / 16:02

1 answer

0

The best thing you can do is create the logic in PHP. You can also do it in javascript.

Being able to do something like this.

if(is_numeric($datas['contribuinte'])) {
    $myvar = (int)$datas['contribuinte'];
} else {
    $myvar = $datas['contribuinte'];
}

And now on the front end

onclick="en('.$myvar.');"
    
07.06.2016 / 16:10