Calc.asp

Page source

<HTML> <HEAD> <TITLE>calculation example -- response</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> The sum is: 246 </BODY> </HTML>

Script listing

<HTML> <HEAD> <TITLE>calculation example -- response</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF"> <% dim nbrIn1 'first input number from the form dim nbrIn2 'second input number from the form dim intSum 'the sum, which is returned nbrIn1 = request.form ("txtN1") nbrIn2 = request.form ("txtN2") intSum = int(nbrIn1) + int(nbrIn2) response.write ("The sum is: " & intSum) %> </BODY> </HTML>

Explanation

The script creates three variables, two for the values the user entered (nbrIn1 and nbrIn2) into the form and the third for their sum (intSum). The form method of the request object returns the values the user entered.

After calculating the sum of the inputs, the script writes them to the output page using the write method of the response object.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.