English 中文(简体)
A. 提交年份的工作
原标题:the submit button doesn t work

when i click on the submit button nothing happens , am not sure what is the problem. this program just adds 2 numbers and the output should be an alerts message. please help

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>GlassFish JSP Page</title>
</head>
<body>

    <%
        int a = 6, b = 8, c;
            c=a+b;
    %>
    <p>
            Value 1 =
            <%=a%></p>
    <p>
            Value 2 =
            <%=b%></p>
    <p>
            Enter the value :<br /> <input type="text" id="c" /></br>
                <input type="submit" value="Submit"
                    onclick="validate();" />
    </p>
    <script type="text/javascript">

            function validate() {
                    var a = <%=a%>;
                    var b = <%=b%>;
                    var c = <%=c%>;
                    if (c!= parseInt(document.getElementById("c").value, 10))
                            alert("The values you entered is incorrect.");
                    } else {
                            alert("Correct!");
                    }
            }
    </script>
</body>
</html>
最佳回答

如果发言的话,你就没有开张。

if (c!= parseInt(document.getElementById("c").value, 10))

应当:

if (c!= parseInt(document.getElementById("c").value, 10)){
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签