根据昨天的思路,今天扩张了一下功能,页面有4个控件做例子,两个textbox两个button,输完第一个textbox1后敲击回车,自动提交按钮button1,输textbox2回车对应按钮button2
1 <script language="javascript" type="text/javascript">
2
3 var txt1 = document.getElementById("<%=Textbox1.ClientID%>");
4 txt1.onkeydown = txtsubmit1;
5
6 var txt2 = document.getElementById("<%=TextBox2.ClientID%>");
7 txt2.onkeydown = txtsubmit2;
8
9 function txtsubmit1() {
10 if (event.keyCode == 13) {
11 document.getElementById("<%=Button1.ClientID%>").click();
12 return false;
13 }
14 }
15 function txtsubmit2() {
16 if (event.keyCode == 13) {
17 document.getElementById("<%=Button2.ClientID%>").click();
18 return false;
19 }
20 }
21 </script>

相关文章:

  • 2022-12-23
  • 2021-07-18
  • 2022-01-09
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2021-07-06
  • 2021-06-05
  • 2021-07-12
  • 2022-12-23
  • 2021-06-03
相关资源
相似解决方案