[ASP.NET]按鍵跳轉以及按Enter以不同參數提交,及其他感應事件
2024-07-10 13:05:29
供稿:網友
 
菜鳥學堂: 
<html>
<head>
<meta http-equiv="content-language" content="zh-cn">
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>按鍵跳轉測試</title>
<script language=javascript>
 function keypress()
 {
 akey = event.keycode;
 if(akey ==13)
 {
 gotourl = 'find.aspx?'+event.srcelement.name+'='+event.srcelement.value;
 window.open(gotourl);
 }
 }
 function keytab1(event)
 {
 akey = event.keycode;
 if(akey ==13)
 {
 document.forms[0].useraddr.focus();
 }
 }
 function keytab2(event)
 {
 akey = event.keycode;
 if(akey ==13)
 {
 document.forms[0].userphone.focus();
 }
 } 
 function converttoupper(textbox) 
 {
 textbox.value = textbox.value.touppercase();
 } 
 function checknum(str)
 {
 return str.match(/d/)==null
 }
 
</script>
<style>
<!--
body { font-size: 10pt; font-family: 宋體 }
div { border-style: ridge; border-width: 1px; padding: 10px; background-color:#daf4fe }
-->
</style>
</head>
<body onload="javascript:document.forms[0].userid.focus()">
<div style="width=254px; height:134px">
<form method="post">
<b>查詢條件</b>
<hr>
用戶編碼:<input type="text" name="userid" size="20" onmouseover="this.focus()" onkeypress="keypress()" onfocus="this.select()"><font face="webdings">n</font><br>
用戶姓名:<input type="text" name="username" size="20" onmouseover="this.focus()" onkeypress="keypress()" onfocus="this.select()"><font face="webdings">n</font><br>
用戶電話:<input type="text" name="userphone" onmouseover="this.focus()" onchange="converttoupper(this)" onkeypress="keytab1(event)" onfocus="this.select()"><br>
用戶地址:<input type="text" name="useraddr" onmouseover="this.focus()" onchange="converttoupper(this)" onkeypress="keytab2(event)" onfocus="this.select()">
</form>
</div>
</body>
</html>