Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
script language="javascript">
                function addNumbers()
                {
                        var val1 = parseInt(document.getElementById("value1").value);
                        var val2 = parseInt(document.getElementById("value2").value);
                        var ansD = document.getElementById("answer");
                        ansD.value = val1 + val2;
                        var val3 = parseFloat(document.getElementById("value3").value)
                        var res = document.getElementById("result");
                        res.value = val1 + val2+val3;
                }
        </script>
  </head>
  <body>
        value1 = <input type="text" id="value1" name="value1" value=""/><br>
        Value2 = <input type="text" id="value2" name="value2" value=""/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" name="Submit" value="Click here" onclick="javascript:addNumbers()"/><br>
        answer = <input type="text" id="answer" name="answer" value=""/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" name="Submit" value="Click here" onclick="javascript:addNumbers()"/><br>
        Value3 = <input type="text" id="value3" name="value3" value=""/><br>
        result =<input type="text" id="result" name="result" value=""/>
Posted
Updated 13-Oct-15 0:08am
v2
Comments
[no name] 13-Oct-15 6:03am    
please explain your issue in detail .
phil.o 13-Oct-15 6:38am    
Not a question.
Naveen.Sanagasetti 13-Oct-15 7:25am    
Please provide the error details, which you have faced while using this code blocks.

1 solution

The language attribute has been deprecated for a long time, and should not be used.
<script type="text/javascript"></script>
This is the correct one.

But according to the W3C, if you don't specify the type for HTML5, it'll considered as javascript by default.


-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900