我正在使用JQuery创建自动填充输入文本。 问题是删除输入后,结果仍然显示:
这是剧本:
Dim str As String
Dim transtype As String
Dim transid As String
Dim quantityout As Integer
Dim discount As Integer
Dim remarks As String
cnn.Open()
For x As Integer = 0 To DataGridView1.Rows.Count - 1
transtype = "PI"
transid = 1
quantityout = 0
discount = 0
remarks = "Nothing"
str = "insert into purchase.detail (TransactionType, TransactionId, ItemId, BatchNo, Rate, ExpiryDate, Quantity, QuantityOut, Total, Discount, Remarks) values (@transtype, @transid, @ItemId, @BatchNo, @Rate, @ExpiryDate, @Quantity, @qout, @Total, @discount, @remarks)"
Dim cmd3 As New SqlCommand(str, cnn)
cmd3.Parameters.AddWithValue("@ItemId", DataGridView1.Rows(x).Cells("itemid").Value)
cmd3.Parameters.AddWithValue("@BatchNo", DataGridView1.Rows(x).Cells("batchno").Value)
cmd3.Parameters.AddWithValue("@Rate", DataGridView1.Rows(x).Cells("rate").Value)
cmd3.Parameters.AddWithValue("@ExpiryDate", DataGridView1.Rows(x).Cells("expirydate").Value)
cmd3.Parameters.AddWithValue("@Quantity", DataGridView1.Rows(x).Cells("quantity").Value)
cmd3.Parameters.AddWithValue("@transtype", transtype)
cmd3.Parameters.AddWithValue("@transid", transid)
cmd3.Parameters.AddWithValue("@qout", quantityout)
cmd3.Parameters.AddWithValue("@Total", DataGridView1.Rows(x).Cells("total").Value)
cmd3.Parameters.AddWithValue("@discount", discount)
cmd3.Parameters.AddWithValue("@remarks", remarks)
cmd3.ExecuteNonQuery()
cmd3.Dispose()
Next
cnn.Close()
这是HTML部分:
function autocomplet() {
var min_length = 0; // min caracters to display the autocomplete
var keyword = $('#especialidad_doctor').val();
if (keyword.length >= min_length) {
$.ajax({
url: 'buscar_especialidad.php',
type: 'POST',
data: {keyword:keyword},
success:function(data){
$('#especialidad_id').show();
$('#especialidad_id').html(data);
}
});
} else {
$('#especialidad_id').hide();
}
}
我该如何解决这个问题?
答案 0 :(得分:1)
删除equal
标志。如果您的输入没有字符,则其长度为0
,因此与>= min_length
相比,它会返回true
。所以else
,块将不再起作用
if (keyword.length > min_length) {
}
答案 1 :(得分:0)
您可以使用Easyautocomplete它功能强大且易于设置: