本文介绍了将光标聚焦到每行的第一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




每当我在

第二个文本框中按下两个标签时我写了代码来生成一个新行文本框。它工作正常。但我的问题是

在我按Tab键时创建的新行中,光标应该在第一个

文本框中。我为此编写了代码。它是第10行和第11行。

它不起作用。请让我知道解决方案。

当我在第一行的第二个文本框中按Tab键时,光标将转到第二行的第二个文本框,当我按第二个文本中的tab时第二排光盘完全没有看到。>
我花了很多时间在这上面。



提前致谢。

html文件如下。


< html>

< ; head>

< script>

var numOfLines = 2;

函数generateRow()

{

var d = document.getElementById(" div");

d.innerHTML + ="< input type =''text''name =''quantity" ; + numOfLines +"''>& nbsp& nbsp" ;;

d.innerHTML + ="< input type =''text''name =''itemCode" + numOfLines +"''onkeydown =''if(event.keyCode == 9){generateRow();}''>< BR>" ;

var felement = eval(" document.forms [0] .quantity" + numOfLines);

felement.focus();

numOfLines + = 1;

}


< / script>

< / head>

< body>

< form>


数量& nbsp& nbsp ItemCode< br>

< ; input type = text name =" quantity1" >

< input type =" text"命名= QUOT; itemcode1" onkeydown =" if(event.keyCode == 9){generateRow();}">


< div id =" div">< / div> ;

< / form>

< body>

< / html>

Hi,

I wrote the code to generate a new row each time when i press tab in the
second text box in a row of two text boxes. It''s working fine. But my problem is
in the new row that is created when i press tab, the cursor should be in the first
text box. I wrote the code for that. It''s line 10 and 11.
It''s not working. Please let me know the solution.
More over when i press tab in the 2nd text box of first row the cursor is going to
second text box of second row and when i press tab from the second text box of
second row the cursor is not at all seen.
I spent a lot of time on this.


Thanks in advance.
The html file is below.


<html>
<head>
<script>
var numOfLines = 2;
function generateRow()
{
var d=document.getElementById("div");
d.innerHTML += "<input type=''text'' name=''quantity"+numOfLines+"''>&nbsp&nbsp";
d.innerHTML += "<input type=''text'' name=''itemCode"+numOfLines+"'' onkeydown=''if(event.keyCode==9){generateRow();}''>< br>" ;
var felement = eval("document.forms[0].quantity"+numOfLines);
felement.focus();
numOfLines += 1;
}

</script>
</head>
<body>
<form>

Quantity &nbsp&nbsp ItemCode<br>
<input type=text name="quantity1" >
<input type="text" name="itemcode1" onkeydown="if(event.keyCode==9) {generateRow();}">

<div id="div"></div>
</form>
<body>
</html>

推荐答案




这篇关于将光标聚焦到每行的第一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:50