如何使用eventArgs e(经典asp)调用jscript onFormSubmit()

时间:2010-03-05 06:05:42

标签: asp-classic javascript

如果我在经典的asp页面上有以下jscript代码,我如何在调用中提供“eventArgs e”,以便在jscript中可以使用它? “eventArgs e”是一个asp.net术语,我不确定这里使用的是什么。

response.write "<script type='text/javascript'>"
response.write "function onFormSubmit(e)"
response.write "{ var keycode;"
response.write "if(window.event) keycode = window.event.keyCode;"
response.write "else if (e) keycode = e.which;"
response.write "else return true;"
response.write "if (keycode == 13)"
response.write "{ myform.submit();"
response.write "return false; }"
response.write "else return true; }"
response.write " </script>"

电话看起来像这样:

response.write "<form name='myform' action='logon' method='post' onSubmit='onFormSubmit()'>"

谢谢你, 吉姆

1 个答案:

答案 0 :(得分:0)

修改:让我们全面解决。这对你有用吗?

<%@ Language=VBScript %>
<html>
<head>
    <title>test</title>
    <script type="text/javascript">
      function submitIfEnter(e)
      {
      var keycode;
      if (window.event) keycode = window.event.keyCode;
      else if (e) keycode = e.which;
      else return true;

      if (keycode == 13)
         {
         var f = document.myform;
         f.action.value = "Forum Logon";
         f.submit();
         }
      }
    </script>
</head>
<body>

  <% 
  if request.form("action") <> "" then 
     response.write "submit value = " + request.form("bsubmit") + "<br />"
     response.write "action value = " + request.form("action") + "<br />"
  else
  %>
  <form method="post" name="myform">
    <input type="text" onkeydown="submitIfEnter(event);"/>
    <input type='hidden' name='action' value='action1'>
    <input type='submit' name='bsubmit' value='Guest Register'>
    <input type='submit' name='bsubmit' value='Forum Logon'>
  </form>
  <% 
  end if
  %>
</body>
</html>