I was trying to add product details to table based on product name which can be collected from following input box.
<input type="text" autofocus class="form-control" id="productSearch" placeholder="Product name">
But the problem is it can't empty the text box after adding the value and go to previous input box. How do i make it empty and focus only same input box?
$( "#productSearch" ).change(function(event) {
$.ajax({
type: "get",
url: "{!! asset('searchByProductName') !!}",
dataType: 'json',
data: { name:this.value },
success: function(response){
if ($('#' + response.id).length !== 0) {
return false;
}
var markup = "<tr id="+response.id+"><input type='hidden' name='product_id[]' value="+response.id+"><td><i class='flaticon-delete-1 delete-row' onclick='deleteRow(this)'></i></td><td>"+response.product_name+"</td><td>"+response.product_unit_price+"</td><td><input type='text' name='quantity[]' class='quantity' value='1'></td><td class='total'>"+response.product_unit_price+"</td><td>"+response.notes+"</td></tr>";
$("table tbody").append(markup);
$(this).val("");
return false;
event.preventDefault();
}
});
});