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