Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Enter键在fieldset元素内的字段之间移动_Javascript_Html - Fatal编程技术网

Javascript 使用Enter键在fieldset元素内的字段之间移动

Javascript 使用Enter键在fieldset元素内的字段之间移动,javascript,html,Javascript,Html,没有字段集,输入(返回键)有效 如果我在表单中需要fielset,我该怎么办?如果我添加字段集 <HTML> <Head> <Script Language=JavaScript> function toEOT(isField){ isRange = isField.createTextRange(); isRange.move('textedit'); isRange.select(); } function actTab(isField){ if

没有
字段集
,输入(返回键)有效

如果我在表单中需要
fielset
,我该怎么办?如果我添加
字段集

<HTML>
<Head>
<Script Language=JavaScript>

function toEOT(isField){

isRange = isField.createTextRange();
isRange.move('textedit');
isRange.select();
}

function actTab(isField){

if (event.keyCode == 13)
{
nextField = isField.tabIndex;
nextField++;
if (nextField < document.forms.Form1.length)
{document.forms.Form1[nextField].focus()}
else {document.forms.Form1[0].focus()}
}
}

function init(){

document.forms.Form1[0].focus();
}

window.onload=init;

</Script>
</Head>
<Body>
<Form name='Form1'>
<fieldset>
<legend>Fills</legend>
<input type=text value="This is Some Text" size=25 onfocus="toEOT(this)" onkeyup="actTab(this)" tabindex='0'><br>
<input type=text value="Some Text" size=25 onfocus="toEOT(this)" onkeyup="actTab(this)" tabindex='1'><br>
<input type=text value="Nothing" size=25 onfocus="toEOT(this)" onkeyup="actTab(this)" tabindex='2'><br>
<input type=text value="Two Words" size=25 onfocus="toEOT(this)" onkeyup="actTab(this)" tabindex='3'><br>
</fieldset>
</Form>
</Body>
</HTML>

函数toEOT(isField){
isRange=isField.createTextRange();
isRange.move('textedit');
isRange.select();
}
功能actTab(isField){
如果(event.keyCode==13)
{
nextField=isField.tabIndex;
nextField++;
if(nextField




尝试将
tabindex
参数增加1,使其从1开始,而不是从0开始


tabindex
用于正整数,除非您试图实现与
tabindex
通常设计的功能稍有不同的功能。在

上阅读更多信息我只需在每个输入元素上添加一个索引作为id或类,然后在actTab函数中,您可以从id或类中读取索引值,然后您可以使用jquery选择下一个输入

如果我的回答解决了您的问题,请将其标记为正确答案。如果没有,请评论,以便我可以尝试进一步协助:)