jQuery Autocomplete deletes selected text

I have a strange issue where a user enters a name and it returns the value the odd thing is that some names it just deletes what was auto complete and others it works fine. For example on the same page I can enter: Mar and it will display say: Martin Mac 250 click on the result and it fills in all the right fields[Id, description, price etc] but I enter SM it will enter all the right fields but delete the text in the description box (where the auto complete is). Its very odd and I cant find what could cause it! Here is the code:

jQuery:

[php]$(document).ready(function() {

// Use the .autocomplete() method to compile the list based on input from user
$("#desc").autocomplete(“inc/get_item.php”, {
width: 260,
//matchContains: true,
mustMatch: true,
minChars: 2,
//multiple: true,
//highlight: false,
//multipleSeparator: “,”,
selectFirst: true
});

$("#desc").result(function(event, data, formatted) {
$("#code").val(data[1]);
$("#price").val(data[2]);
$("#con").val(data[3]);
$(“input[id=‘q’]”).focus();
});

// Use the .autocomplete() method to compile the list based on input from user
$("#customer").autocomplete(“inc/get_customer.php”, {
width: 260,
matchContains: true,
mustMatch: true,
minChars: 2,
//multiple: true,
//highlight: false,
//multipleSeparator: “,”,
selectFirst: true
});

$("#customer").result(function(event, data, formatted) {
$("#customerid").val(data[1]);
});

// Use the .autocomplete() method to compile the list based on input from user
$("#del-desc").autocomplete(“inc/get_del.php”, {
width: 260,
matchContains: true,
mustMatch: true,
minChars: 2,
//multiple: true,
//highlight: false,
//multipleSeparator: “,”,
selectFirst: true
});

$("#del-desc").result(function(event, data, formatted) {
$("#del-price").val(data[1]);
});
}); [/php]
Part of the HTML:

[php]

Customer Name


Another part:
                    <td><input type="text" name="item[<?php echo count($item);?>][desc]" id="desc" class="inputbox b300" value="" /></td>

                    <td><input type="text" name="item[<?php echo count($item);?>][price]" id="price" class="inputbox b50" value="0.00" readonly/></td>

                    <td><input type="text" name="item[<?php echo count($item);?>][q]" id="q" class="inputbox b20" value="0" /></td>

                    <td><input type="text" name="item[<?php echo count($item);?>][discount]" id="discount" class="inputbox b50" value="0" /></td>

                        <input type="hidden" name="item[<?php echo count($item);?>][con]" id="con" value="" />

                    <td>&nbsp;</td><td>&nbsp;</td><td><input name="action" type="submit" value="Update Invoice" class="btnalt"></td>[/php][/code]
Sponsor our Newsletter | Privacy Policy | Terms of Service