我的程序是这样的:
<form name="form1" action="" method="post" >
<input id=kw maxlength=100 size=32 name=uaccount value=""/> <input id=sb type="submit" name="btnlook" value=btnlook onKeyDown="return KeyDownHandler(btnlook);" /> <input id=sb type="submit" name="submituser" value=submituser />
</form>
<script type="text/Jscript">
function KeyDownHandler(btnEnter)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
document.form1.action="save_index.asp"
btnEnter.click();
}
}
</script> 多个submit按钮,怎么实现按回车键提交表单?
回车后,就是不能让其中一个按钮自动提交!为什么?
<form name="form1" action="" method="post" >
<input id=kw maxlength=100 size=32 name=uaccount value=""/> <input id=sb type="submit" name="btnlook" value=btnlook onKeyDown="return KeyDownHandler(btnlook);" /> <input id=sb type="submit" name="submituser" value=submituser />
</form>
<script type="text/Jscript">
function KeyDownHandler(btnEnter)
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
document.form1.action="save_index.asp"
btnEnter.click();
}
}
</script> 多个submit按钮,怎么实现按回车键提交表单?
回车后,就是不能让其中一个按钮自动提交!为什么?
<form name="form1" action="" method="post" >
<input id=kw maxlength=100 size=32 name=uaccount onKeyDown="KeyDownHandler();" value=""/> <input id=sb type="submit" name="btnlook" value=btnlook /> <input id=sb type="submit" name="submituser" value=submituser />
</form>
<script type="text/Jscript">
function KeyDownHandler()
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
document.form1.action="save_index.asp"
form1.btnlook.click();
}
}
</script>
如果想在整个页面按回车
<form name="form1" action="" method="post" >
<input id=kw maxlength=100 size=32 name=uaccount value=""/> <input id=sb type="submit" name="btnlook" value=btnlook /> <input id=sb type="submit" name="submituser" value=submituser />
</form>
<script type="text/Jscript">
document.onkeydown=KeyDownHandler;
function KeyDownHandler()
{
// process only the Enter key
if (event.keyCode == 13)
{
// cancel the default submit
event.returnValue=false;
event.cancel = true;
// submit the form by programmatically clicking the specified button
document.form1.action="save_index.asp"
form1.btnlook.click();
}
}
</script>
<input id='kw' maxlength='100' size='32' name='uaccoun't value=""/><input id='sb' type="button" name="btnlook" value='btnlook' /><input id='sb2' type="button" name="submituser" value='submituser' />
</form>
<script type="text/Jscript">
document.body.onkeypress=
function CheckEnter()
{
if (event.keyCode == 13 ){
document.form1.action="save_index.asp"
document.all.btnlook.focus();
document.form1.submit();
return false;
}
}
</script>