按下回车键时自动切换焦点
本人js新手,编写 按下回车键时自动切换焦点 功能时,出现一些错误,不知道哪出错,请前辈指出,谢谢<table width="86%" align="center" border="0">
<form name="form4" onreset="return AllReset()">
<tr>
<td align="right">商品名称:</td>
<td align="left">
<input type="text" name="txt1" onkeydown="MyEnter('txt3')"/>
</td>
</tr>
<tr>
<td align="right">所属类别:</td>
<td align="left">
<select name="txt2">
<option value="家用电器">家用电器</option>
<option value="礼品工艺">礼品工艺</option>
</select>
</td>
</tr>
<tr>
<td align="right">商品编号:</td>
<td align="left">
<input type="text" name="txt3" id="txt3" />
</td>
</tr>
<tr>
<td height="22" colspan="2" align="center">
<input type="submit" value="提交" onclick="form4.submit()"/>
<input type="reset" value="重置"/>
</td>
</tr>
</form>
</table>
js代码:
function MyEnter(idStr)
{
var ev = event ? event :(window.event ? window.event : null);
if(ev.keyCode==13)
document.getElementById(idStr).focus();
}