【问题标题】:javascript call from JSP [closed]来自 JSP 的 javascript 调用 [关闭]
【发布时间】:2015-01-14 17:58:39
【问题描述】:

我想调用 javascript 函数,但不是调用 javascript 函数,而是通过访问 SERVLET 重定向到另一个 JSP 页面。 我从链接中找到了帮助,他也使用了与我相同的过程。

我找到的链接:javascript function in jsp page

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>

</head>
<body>
    <script type="text/javascript">
        function callCommom() {
            alert("Method Called");
            return (false);
        }
    </script>
    <form action="Common" method="post" onsubmit="return callCommon()">
        <table align="center" border="1">
            <tr>
                <td align="center">Assignment</td>
            </tr>
            <tr>
                <td>
                    <table align="center" border="1">
                        <tr>
                            <td><label>Assignment Number</label></td>
                            <td><input type="text" name="assnName" id="assnname">
                            </td>
                        </tr>
                        <tr>
                            <td align="center"><input type="submit" value="submit"></td>
                            <td align="center"><input type="button" name="btnClear"
                                id="clearButton" value="Clear"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

请给我建议...我需要你的帮助。

【问题讨论】:

  • 您是在提交到 servlet 之前尝试在 javascript 中验证表单,还是根本不想提交到 servlet?
  • 你可以在提交按钮上使用onclick调用相同的功能

标签: java javascript jsp


【解决方案1】:

有一个错字错误。必须是:

<form action="Common" method="post" onsubmit="return callCommom()">
                                                              ^

或者:

function callCommon() {
                  ^

【讨论】:

  • 天啊!!非常感谢...我正在打破我的头,但我没有注意到它。 :)
  • 不客气。 - 不用担心。这些事情都会发生。很高兴能提供帮助。 :)
猜你喜欢
  • 1970-01-01
  • 2016-05-29
  • 2011-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-29
  • 1970-01-01
  • 2014-11-05
相关资源
最近更新 更多