add two numbers using html

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piyush jain
    New Member
    • May 2007
    • 3

    add two numbers using html

    can we add numbers just only using html
    if not then what is the best way to do the same
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    No. HTML is not a programming language. Use javascript.

    Comment

    • piyush jain
      New Member
      • May 2007
      • 3

      #3
      Originally posted by drhowarddrfine
      No. HTML is not a programming language. Use javascript.
      thanks for the sugestion

      Comment

      • alphaskt
        New Member
        • Jun 2007
        • 1

        #4
        We cannot add two numbers using HTML.You can use javascript for that
        the code for this program is
        Code:
        <html>
        <head>
        <script>//javascript code
        a=15;//initialization of variables
        b=20;
        c=a+b;//perform sum operation
        document.write("sum of numbers is: " +c);//print the result(+ is a concatenate operator)
        </script>
        </head>
        </html>
        Last edited by acoder; Oct 27 '11, 09:42 PM.

        Comment

        • drhowarddrfine
          Recognized Expert Expert
          • Sep 2006
          • 7434

          #5
          Warning: the html and code listed in the above post is out of date (deprecated) and should not be used, though it will work. For modern methods, ask on the javascript board.

          Comment

          • amarlol
            New Member
            • Oct 2011
            • 1

            #6
            check this code out, its for a calculator



            Code:
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Untitled Document</title>
            </head>
            
            <body>
            <form name="Calc">
            <table border=1>
            <tr>
            <td>
            <input type="text" name="Numbers" size=16 />
            </td>
            </tr>
            <tr>
            <td>
            <input type="button" value="  1  " onClick="document.Calc.Numbers.value += '1'"/>
            <input type="button" value="  2  " onClick="document.Calc.Numbers.value += '2'"/>
            <input type="button" value="  3  " onClick="document.Calc.Numbers.value += '3'"/>
            <input type="button" value="  +  " onClick="document.Calc.Numbers.value += '+'"/>
            <br />
            <input type="button" value="  4  " onClick="document.Calc.Numbers.value += '4'"/>
            <input type="button" value="  5  " onClick="document.Calc.Numbers.value += '5'"/>
            <input type="button" value="  6  " onClick="document.Calc.Numbers.value += '5'"/>
            <input type="button" value="  -  " onClick="document.Calc.Numbers.value += '-'"/>
            <br />
            <input type="button" value="  7  " onClick="document.Calc.Numbers.value += '7'"/>
            <input type="button" value="  8  " onClick="document.Calc.Numbers.value += '8'"/>
            <input type="button" value="  9  " onClick="document.Calc.Numbers.value += '9'"/>
            <input type="button" value="  x  " onClick="document.Calc.Numbers.value += '*'"/>
            <br />
            <input type="button" value="  AC  " onClick="document.Calc.Numbers.value = ' '"/>
            <input type="button" value="  0  " onClick="document.Calc.Numbers.value += '0'"/>
            <input type="button" value="  7  " onClick="document.Calc.Numbers.value += '7'"/>
            <input type="button" value="  =  " onClick="document.Calc.Numbers.value = eval(Calc.Numbers.value)"/>
            <br />
            </td>
            </tr>
            </table>
            </body>
            </html>
            Last edited by acoder; Oct 27 '11, 09:43 PM. Reason: Added [code] tags

            Comment

            Working...