JavaScript に少し問題があり、お役に立てれば幸いです。
ここの例を使用しています: http://www.knowlbase.in/2012/01/traverse-cursor-through-text-box-with.htmlページ上のテキストボックス間を移動します。左と右はうまく機能しますが、上下にカーソルを斜め右に移動します(ただし、上キーを押すと斜め上に移動し、下キーを押すと斜め下に移動します)。
誰が私が間違っているのかを見ることができますか?
これは私が持っているものです:
function arrowKeyPressed() {
$('input').keyup(function (e) {
if (e.which == 39)
$(this).closest('td').next().find('input').focus();
else if (e.which == 37)
$(this).closest('td').prev().find('input').focus();
else if (e.which == 40)
$(this).closest('tr').next().find('td:eq(' + $(this).closest('td').index() + ')').find('input').focus();
else if (e.which == 38)
$(this).closest('tr').prev().find('td:eq(' + $(this).closest('td').index() + ')').find('input').focus();
});
};
そして、これがテキストボックス属性を追加する方法です(すべてのテキストボックスはプログラムで作成されます):
tb.Attributes.Add("onkeyup", "arrowKeyPressed()");
生成時の HTML は次のようになります (これは 1 つのテキスト ボックスのみです。タブ インデックスを除いて、他のすべては同じです)。
<input name="ctl00$MainContent$addPrices$Textbox101"
type="text"id="ctl00_MainContent_addPrices_Textbox101" tabindex="13"
onblur="validateText('ctl00_MainContent_addPrices_Textbox101',
'ctl00_MainContent_addPrices_AddQuote', 'ctl00_MainContent_addPrices_msgLbl')"
style="width:60px;">
何か案は?
ありがとう!