2017-10-26 5 views
0

amountフィールドに何かを入力したときにadd()関数を呼び出すと、タブを押すと呼び出されます。しかし、amountの隣にあるフィールドは読み取り専用モードになっています。私は誰が私に解決策を提案してください以下のようなコードを試してみました。、javacriptを使用したタブプレスでの問題

$('#price_1').on('keyup', function(e) { 
if(e.which == 9) { 
var i=$('table tr').length; 
html = '<tr>'; 
html += '<td><input class="case" type="checkbox"/></td>'; 
html += '<td><input type="text" data-type="productName" autocomplete="" name="itemName[]" id="itemName_'+i+'" id="productList" class="form-control autocomplete_txt item2" tabindex="0" value=""style="text-align:center;" autofocus></td>'; 
html += '<td><input type="number" name="quantity[]" id="quantity_'+i+'" class="form-control changesNo" autocomplete="off" tabindex="0" onkeypress="return IsNumber(event);" ondrop="return false;" onpaste="return false;"></td>'; 
html += '<td><input type="number" name="price[]" id="price_'+i+'" class="price1 form-control changesNo" autocomplete="off" tabindex="0" onkeypress="return IsNumber(event);" ondrop="return false;" onpaste="return false;"></td>'; 
html += '<td><input type="number" name="total[]" id="total_'+i+'" class="form-control totalLinePrice" autocomplete="off" tabindex="-1" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" readonly></td>'; 
html += '</tr>'; 
$('table').append(html); 
$(".item2").autocomplete({ 
source: "https://www.duminex.com/product/search", 
select: function(event, ui) { 
var a = i - 1; 
$('#id').val(ui.item.id); 
$('#price_' + a).val(ui.item.price); 
} 
}); 
i++; 
} 
}); 
<td><input type="text" tabindex="6" name="price[]" id="price_1" class="form-control changesNo" autocomplete="off" onkeypress="return IsNumber(event);" onpaste="return false;" required="required" ></td> 

<td><input type="text" name="total[]" id="total_1" class="form-control totalLinePrice" autocomplete="off" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;" required="required" ></td> 

enter image description here

+0

次のフィールドは現在のアクションに依存しません。私はあなたの機能がタブを押すことで呼び出されていないと思う。 –

+0

それから、関数呼び出しで@harsh –

+0

関数の問題が起きています。直前のフィールドのタブを直ちに押すと呼び出されます。しかし、値フィールドからのみタブを押すと関数が呼び出されるようにします –

答えて

1

フィールドがフォーカスを失った後どうやら、keyUpイベントが呼び出されます。金額欄に登録することは役に立ちません。参考:

jQuery: keyup for TAB-key?

また、どのような要件のような、アドオン()関数は、ユーザが金額フィールド以外の場所をクリックするだけとされていない場合、タブを押し上で起こることがあるがありますか?それとも、フィールド上でフォーカスが失われても問題ありませんか?フィールド上のどこかをクリックするようなものもあります。...

関連する問題