I am calling a javascript function from php using a print statement to print out html code, and I am passing in an integer. However, the value when it is passed in php is no
Solve it by creating a hidden text called it 'tempcart' then assing value to it with HTML or PHP, it will keep the leading zeros intact as a text string. To make sure, convert it to string if you are passing it thru PHP
HTML:
PHP:
$itemID = '0011110416605';
$itemID = strval( $itemID );
echo "";
SCRIPT:
function removeFromCart() {
var itemID = document.getElementById('tempcart').value;
alert(itemID);
//do whatever...
}
This is just sample programming, you need to fit it in your program. I guess Javascript can't pass due to convertion to octal value (because of the leading zero and the lack of digits greater than 7) as @Vivid mention before.