0

Hey guys, new to javascript. I was just wondering could you point me in the right direction as to where i might be going wrong. Please see code below.

<%@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>JSP Page</title>
        <script language="JavaScript">function myadd(a,b){
            document.addForm.result.value=parseInt(a)+parseInt(b);
        }
        </script>
    <noscript>JavaScript is not enabled!</noscript>
    </head>
    <body>
        
        Number 1: <input type="text" name ="num1" /><br>
        Number 2: <input type="text" name ="num2" /><br>
        Result: <input type="text" name ="result" /><br>
        <input type="button" value="Add the numbers" onclick="myadd(document.addForm.num1.value, document.addForm.num2.value)">
            
    </body>
</html>

When I press the button for the answer, it doesn't show it. Any ideas? Thanks in advance

1
Contributor
2
Replies
4
Views
7 Years
Discussion Span
Last Post by Bobon
0

No worries guys I got the answer. I never added in the form.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.