js怎么实现回车直接提交?
例a.asp页面以下代码:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.o...
例a.asp页面以下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function document.onkeydown() {
if(event.keyCode == 13) {
document.getElementById("enter").click();
return false;
}
}
</script>
</head>
<body>
<form id="form">
<input type="text" name="name" id="name" />
<input type="button" id="enter" name="aaaa" onclick="location.href = 'b.asp?name='+document.getElementById('name').value;" value="提交" />
<input type="reset" name="Submit" onclick="document.getElementById('name').reset();" value="重置" />
</form>
</body>
</html>
上面的代码怎么实现回车后到b页面b.asp?name= 而不是只有点提交才能到b.asp?name= 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
function document.onkeydown() {
if(event.keyCode == 13) {
document.getElementById("enter").click();
return false;
}
}
</script>
</head>
<body>
<form id="form">
<input type="text" name="name" id="name" />
<input type="button" id="enter" name="aaaa" onclick="location.href = 'b.asp?name='+document.getElementById('name').value;" value="提交" />
<input type="reset" name="Submit" onclick="document.getElementById('name').reset();" value="重置" />
</form>
</body>
</html>
上面的代码怎么实现回车后到b页面b.asp?name= 而不是只有点提交才能到b.asp?name= 展开
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>
无标题文档
</title>
<script language="javascript">
document.onkeydown = function(e) {
e = e || window.event;
if(e.keyCode == 13) {
this.forms["form"].submit();
return false;
}
}
</script>
</head>
<body>
<form id="form" action="b.asp" method="get">
<input type="text" name="name" />
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询