Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to write the Script for adding two numbers in two text boxes and print the Result on the 3rd text box on web Application ?

pls help me sir....!
Posted
Comments
Sergey Alexandrovich Kryukov 10-Jan-12 1:53am    
Script? Do you mean JavaScript (on client side), or you want to do calculations on server side? (If this is only JavaScript, ASP.NET is irrelevant.)
--SA
Sergey Alexandrovich Kryukov 12-Jan-12 3:04am    
Stop re-posting this question! (I'll remove your next post.) You have an answer, why do you asking again. Comment on Griff's question if you are not satisfied.
--SA

1 solution

Assuming by script you mean Javascript:
XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1250">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <title></title>
    <SCRIPT language = JavaScript>

      function calculate() {
        A = eval(no1.value)
        B = eval(no2.value)
        C = (A + B)
        result.value = C
        }

    </SCRIPT>
  </head>
  <body>
    First Number : <input type="text" name="no1" /><br />
    Second Number: <input type="text" name="no2" /><br />
    Resulting num: <input type="text" name="result" /><br />
    <Input Type = Button name = b1 value = "Add Numbers" onClick = calculate()>
  </body>
</html>
 
Share this answer
 
Comments
sunil from madras 12-Jan-12 2:58am    
Thanks but i have to print the result without using button directly when we enter an number, it has to print the correct answer to the third text box........
OriginalGriff 12-Jan-12 3:44am    
Then put the function call in the relevant event - the onChange one could be useful...

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