title: Setting value of a string on click
body: <p>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. </p>
  
  <p>For exmaple this is what is returned when searching...</p>
  
  <pre><code>pID: "&lt;a class='result' onclick='setID(0001-001-004)' href='#'&gt;Product Code=0001-001-004, White Folding Chair&lt;/a&gt;"
  </code></pre>
  
  <p>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.</p>
  
  <p>The code for the setID function is...</p>
  
  <pre><code>function setID(pID) {
      var prodCode=toString(pID);     
      $('input#productCode').val(pID);
      var clear="";
      $('div#suggestions').html(clear);
      $('div#suggestions').hide(); 
  
  }  
  </code></pre>
  
  <p>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...</p>
  
  <pre><code>$array[] = array (
          "pID" =&gt;"&lt;a class='result' onclick='setID(".$row['ITEMNO'].")' href='#'&gt;Product Code=". $row['ITEMNO'].", " .$row['ITEMDESC']."&lt;/a&gt;"
      );
  </code></pre>