New at this ..Question using with php

New at this ..Question using with php

I am new at this so this might seem like a stupid question.  How do I pass the value in my auto complete text box to my php script ? (see code below).

index.html
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">

  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Ajax Auto Suggest</title>

  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
  7. libs/jquery/1.3.0/jquery.min.js"></script>
  8. <script type="text/javascript">
  9. function lookup(inputString) {
  10. if(inputString.length == 0) {
  11. // Hide the suggestion box.
  12. $('#suggestions').hide();
  13. } else {
  14. $.post("rpc.php", {queryString: ""+inputString+""}, function(data){
  15. if(data.length >0) {
  16. $('#suggestions').show();
  17. $('#autoSuggestionsList').html(data);
  18. }
  19. });
  20. }
  21. } // lookup
  22. function fill(thisValue) {
  23. $('#inputString').val(thisValue);
  24. setTimeout("$('#suggestions').hide();", 200);
  25. }
  26. </script>

  27. <style type="text/css">
  28. body {
  29. font-family: Helvetica;
  30. font-size: 11px;
  31. color: #000;
  32. }
  33. h3 {
  34. margin: 0px;
  35. padding: 0px;
  36. }

  37. .suggestionsBox {
  38. position: relative;
  39. left: 30px;
  40. margin: 10px 0px 0px 0px;
  41. width: 200px;
  42. background-color: #212427;
  43. -moz-border-radius: 7px;
  44. -webkit-border-radius: 7px;
  45. border: 2px solid #000;
  46. color: #fff;
  47. }
  48. .suggestionList {
  49. margin: 0px;
  50. padding: 0px;
  51. }
  52. .suggestionList li {
  53. margin: 0px 0px 3px 0px;
  54. padding: 3px;
  55. cursor: pointer;
  56. }
  57. .suggestionList li:hover {
  58. background-color: #659CD8;
  59. }
  60. </style>

  61. </head>

  62. <body>


  63. <div>
  64. <Form action="insert_new_number.php" method="POST">
  65. <div>
  66. Company Code:
  67. <br />
  68. <input type="text" size="30" value="" id="inputString" name="custid" onkeyup="lookup(this.value);" onblur="fill();" />
  69. </div>
  70. <div class="suggestionsBox" id="suggestions" style="display: none;">
  71. <img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
  72. <div class="suggestionList" id="autoSuggestionsList">
  73. &nbsp;
  74. </div>
  75. </div>
  76.                      <input type="submit" />
  77. </form>
  78. </div>

  79. </body>
  80. </html>

RPC.php

  1. <?php
  2. // PHP5 Implementation - uses MySQLi.
  3. // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase');
  4. $db = new mysqli('localhost', 'xxxxxxx' ,'xxxxxxxx', 'xxxxxxx');
  5. if(!$db) {
  6. // Show error if we cannot connect.
  7. echo 'ERROR: Could not connect to the database.';
  8. } else {
  9. // Is there a posted query string?
  10. if(isset($_POST['queryString'])) {
  11. $queryString = $db->real_escape_string($_POST['queryString']);
  12. // Is the string length greater than 0?
  13. if(strlen($queryString) >0) {
  14. $query = $db->query("SELECT Customer_Code FROM data WHERE Customer_Code LIKE '$queryString%' LIMIT 10");
  15. if($query) {
  16. while ($result = $query ->fetch_object()) {
  17. echo '<li onClick="fill(\''.$result->Customer_Code.'\');">'.$result->Customer_Code.'</li>';
  18.                                         
  19.                                                 }
  20. } else {
  21. echo 'ERROR: There was a problem with the query.';
  22. }
  23. } else {
  24. // Dont do anything.
  25. } // There is a queryString.
  26. } else {
  27. echo 'There should be no direct access to this script!';
  28. }
  29. }
  30. ?>
insert_new_number.php is the script I want to send the data to, from the ajax auto complete text box.  I just can't figure out how to do it.

Thanks