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 not matching the number that the javascript function receives, and I have no clue why.
Here is the php that calls the javascript function:
$upc = $items[$i]->GetUPC();
print "upc: " . $upc . "<br/>";
$delete = "<a href='#' onclick='removeFromCart(". $upc .")'><img src='".$redx."' height='17' width='17' /></a>";
The print statement prints out the value: 0011110416605
And on the page, using view source, here is the tag for this:
<a href='#' onclick='removeFromCart(0011110416605)'>
Here is the javascript function that is being called:
function removeFromCart(itemID){
var option = document.getElementById("select_cart");
var selected = option.options[option.selectedIndex].value;
alert(itemID);
loadCart(itemID,selected,"","remove");
}
The alert box is printing out the number: 1226972549
I could understand if it was removing the leading 0's, but this number is completely different. Does anyone know why this may be?