Display sum in textbox in JavaScript on page as I enter values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sandyyyy35
    New Member
    • May 2013
    • 21

    #1

    Display sum in textbox in JavaScript on page as I enter values

    hi,

    Please provide me the solution for the coed i have provided below, as i want to display a result in average id box at the main webpage. while entering the values.



    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>
    <script>
    function average()
    	{
    		var math = parseInt(document.getElementById('math').value);		
    		var art = parseInt(document.getElementById('art').value);
    		
    		
    		var result = math + art;
    //how could i display this result in a text box of id "average".
    	}
    </script>
    <body>
    
    <input type="text" name="math" id="math" />
    <input type="text" name="art" id="art" />
    <input type="text" name="average" id="average" onmouseover="return average() " />
    </body>
    </html>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how could i display this result in a text box of id "average".
    you set the result as value of that text box.

    Comment

    • sandyyyy35
      New Member
      • May 2013
      • 21

      #3
      Thnx Dormilich. You helped me a lot......

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        no problem, I like helping,

        Comment

        Working...