Autocomplete needing to clear fields if main field is changed.

Autocomplete needing to clear fields if main field is changed.

New to the forum, great forum for a newbie by the way, so this may have been answered somewhere but couldn't find it.

I have the following code on my form.
  1. <script type="text/javascript" src="includes/jquery.js"></script>
  2. <script type='text/javascript' src='includes/jquery.autocomplete.js'></script>
  3. <link rel="stylesheet" type="text/css" href="includes/jquery.autocomplete.css" />

  4. <script type="text/javascript">
  5. $().ready(function() {
  6. $("#org_name").autocomplete("data.php", {
  7. width: 150,
  8. matchContains: true,
  9. mustMatch: false,
  10. selectFirst: false
  11. });

  12. $("#org_name").result(function(event, data, formatted) {
  13. $("#org_id").val(data[1]);
  14. $("#org_location").val(data[2]).attr("disabled",true);
  15. });
  16. });
  17. </script>
and this is the fields that are affected by this.
  1. <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">

  2. <p><label for="org_name"><strong>Organization Name:</strong> </label>
  3.   <input type="text" name="org_name" id="org_name" value="" /> 
  4.   *
  5. </p>
  6. <p><label for="org_location"><strong>Organization Location:</strong> </label>
  7.   <input type="text" name="org_location" id="org_location" value="" />
  8.   <input type="hidden" name="org_id" id="org_id" value="" />
  9. <p>
  10.   <input type="submit" name="button" id="button" value="Submit" />
  11.   <input type="reset" name="button2" id="button2" value="Reset" />
  12. </p>
  13. <input type="hidden" name="MM_insert" value="form1" />
  14. </form>
Here is the code for the data.php page.
  1. $q = strtolower($_GET["q"]);
  2. if (!$q) return;

  3. mysql_select_db($database, $table);
  4. $sql = "select org_name, ID, location from organization where org_name LIKE '$q%'";
  5. $rsd = mysql_query($sql);
  6. while($rs = mysql_fetch_array($rsd)) {
  7. $cid = $rs['ID'];
  8. $cloc = $rs['location'];
  9. $cname = $rs['org_name'];
  10. echo "$cname - $cloc|$cid|$cloc\n";
  11. }
Now everything works great until I want to change the text in the org_name field.  The other two fields, org_location and org_id, will retain the input and I would like them to clear.  I am afraid that my users will make a mistake and choose a suggested outcome and then want to change it.

Being new to jquery, I am sure that there is something simple to fix this.

Thanks