2014-01-29 55 views
0

用提交按钮输入表单字段间的移动键。 我试过这段代码,但它不工作。 此代码是用输入表单字段之间移动键: 它的工作没有提交按钮我应该做怎样的变化朋友请帮我用提交按钮输入表单字段间的移动

<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> 
+1

要在字段间移动,您不应该尝试使用“输入”键。因为它的默认行为是提交表单。所以只需使用TAB序列为每个字段。 – Parixit

+0

您的代码需要通过事件并在所有其他浏览器中进行测试,比如 – mplungjan

+0

@mplungjan此代码无需提交按钮即可使用。它不与提交按钮一起工作我应该做些什么 – user2978559

回答

1

添加的onclick =“返回false;”在提交按钮的输入标签中,然后输入wil将引导您到下一个控件。

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

if if this use - onclick =“return false;”该页面将不会重定向到下一页 – user2978559

+0

在它之前添加一些函数调用并在那里解析你的功能。 – Learner