I am trying to set a value of a productID field by searching the product name. The search returns the correct results and displays them but when clicking the value is being set as if it is a number.
For exmaple this is what is returned when searching...
pID: "<a class='result' onclick='setID(0001-001-004)' href='#'>Product Code=0001-001-004, White Folding Chair</a>"
When the below result is clicked, the value of the input is set as -4. If the number returned was 0001-002-005 it gets set to -5.
The code for the setID function is...
function setID(pID) {
var prodCode=toString(pID);
$('input#productCode').val(pID);
var clear="";
$('div#suggestions').html(clear);
$('div#suggestions').hide();
}
Does anyone have any idea how I can do this. I can not return the id between double or single quotations becasue this is the php that returns the result. as you will see the use of double and single quotes leaves me no way to do it in this way...
$array[] = array (
"pID" =>"<a class='result' onclick='setID(".$row['ITEMNO'].")' href='#'>Product Code=". $row['ITEMNO'].", " .$row['ITEMDESC']."</a>"
);