By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

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

P: 21
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.



Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7. <script>
  8. function average()
  9.     {
  10.         var math = parseInt(document.getElementById('math').value);        
  11.         var art = parseInt(document.getElementById('art').value);
  12.  
  13.  
  14.         var result = math + art;
  15. //how could i display this result in a text box of id "average".
  16.     }
  17. </script>
  18. <body>
  19.  
  20. <input type="text" name="math" id="math" />
  21. <input type="text" name="art" id="art" />
  22. <input type="text" name="average" id="average" onmouseover="return average() " />
  23. </body>
  24. </html>
  25.  
May 30 '13 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
how could i display this result in a text box of id "average".
you set the result as value of that text box.
May 30 '13 #2

P: 21
Thnx Dormilich. You helped me a lot......
May 30 '13 #3

Dormilich
Expert Mod 5K+
P: 8,639
no problem, I like helping,
May 30 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.