html - 输入键以在带有提交按钮的表单字段之间移动

标签 html css

输入键在带有提交按钮的表单字段之间移动。 我试过这段代码,但它不起作用。 此代码是使用回车键在表单字段之间移动: 它在没有提交按钮的情况下工作我应该做些什么改变 friend 请帮助我

<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();
}
event.preventDefault();
window.onload=init;

</Script><br>

</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='1'><br>
<input type=text value="Some Text" size=25 onFocus="toEOT(this)" onKeyUp="actTab(this)" tabindex='2'><br>
<input type=text value="Nothing" size=25 onFocus="toEOT(this)" onKeyUp="actTab(this)" tabindex='3'><br>
<input type=text value="Two Words" size=25 onFocus="toEOT(this)" onKeyUp="actTab(this)" tabindex='4'><br>
<select >
<option>geetha</option>
<option>geetha</option>
<option>geetha</option>
</select>
<select >
<option>geetha</option>
<option>geetha</option>
<option>geetha</option>
</select>
<input type=text value="Two Words" size=25 /><br>
 <input style="margin:20px 20px 20px 250px;" type="submit" name="Submit" value="Submit"/>
</fieldset>
</Form>

最佳答案

添加onclick="return false;"在提交按钮的输入标签中,然后输入将引导您进入下一个控件。

<input style="margin:20px 20px 20px 250px;" type="submit" name="Submit" onclick="return false;" value="Submit"/>

关于html - 输入键以在带有提交按钮的表单字段之间移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21422589/

相关文章:

html - 背景剪辑的随机背景图像

html - 为什么我的 CSS 样式不能在第一行工作?

html - Bootstrap 4 导航栏下拉问题

c# - 从 Internet Explorer 渲染图像

Jquery 偏移量显示相对于固定父级而不是页面的值

html - 如何在 Outlook 2010、Outlook 2007、Outlook 2013 中的图像顶部的文本上提供填充/边距?

html - 过渡背景图像宽度但保持高度

php - 当用户单击浏览器的 "refresh"按钮时如何避免重复?

javascript - 在结束 div 上停止侧边栏

css - 如何设置 12 列、宽度为 960 像素但行宽为 1280 的 Bootstrap 网格?