473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

post the result back to same page??

<html>
<body>
<Form action="calc.asp" method="post" name="calc">
<P>NUM1: <input type="text" name="num1">
<P>NUM2: <input type="text" name="num2">
<P>RESULT: <input type="text" name="result">
<P><input type="submit">
</Form>

I want to write an ASP page to accept 2 numbers, and return the sum on the
same page. Can we do it in pure ASP without JavaScript?? It sounds an easy
problem, and I did that in ASP.NET and JavaScript, but failed in pure ASP
3.0. Here's the attempts, but definitely not what I want because I want the
result back to the text field.

<%
Dim num1, num2, result
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))
result = num1 + num2
Response.Write("<P>Num1 = " & num1)
Response.Write("<P>Num2 = " & num2)
Response.Write("<P>Num3 = " & result)
%>
</body>
</html>
Jul 19 '05 #1
4 14515
If you want the result to be in the text field for the result, you have to
write the result into the value of that form element as such.
<%
Dim num1, num2, result
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))
result = num1 + num2
%>

<html>
<body>
<Form action="calc.asp" method="post" name="calc">
<P>NUM1: <input type="text" name="num1" value="<%=num1%>">
<P>NUM2: <input type="text" name="num2" value="<%=num2%>">
<P>RESULT: <input type="text" name="result" value="<%=result%>">
<P><input type="submit">
</Form>


</body>
</html>

Ray at home


"John Davis" <jr*******@hotmail.com> wrote in message
news:#A**************@TK2MSFTNGP12.phx.gbl...
<html>
<body>
<Form action="calc.asp" method="post" name="calc">
<P>NUM1: <input type="text" name="num1">
<P>NUM2: <input type="text" name="num2">
<P>RESULT: <input type="text" name="result">
<P><input type="submit">
</Form>

I want to write an ASP page to accept 2 numbers, and return the sum on the
same page. Can we do it in pure ASP without JavaScript?? It sounds an easy
problem, and I did that in ASP.NET and JavaScript, but failed in pure ASP
3.0. Here's the attempts, but definitely not what I want because I want the result back to the text field.

<%
Dim num1, num2, result
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))
result = num1 + num2
Response.Write("<P>Num1 = " & num1)
Response.Write("<P>Num2 = " & num2)
Response.Write("<P>Num3 = " & result)
%>
</body>
</html>

Jul 19 '05 #2
<%
dblNum1 = Trim(Request("num1"))
dblNum2 = Trim(Request("num2"))
If IsNUmeric(dblNum1) And IsNumeric(dblNum2) Then
Select Case UCase(Trim(Request("CHOICE")))
Case "ADD"
dblAnswer = CDbl(dblNum1) + CDbl(dblNum2)
Case "SUBTRACT"
dblAnswer = CDbl(dblNum1) - CDbl(dblNum2)
Case "MULTIPLY"
dblAnswer = CDbl(dblNum1) * CDbl(dblNum2)
Case "DIVIDE"
dblAnswer = CDbl(dblNum1) / CDbl(dblNum2)
Case Else
dblAnswer = ""
End Select
End If
%>
<html>
<body>
<form action="addtest.asp" method="post" name="calc" ID="Form1">
NUM1: <input type="text" name="num1" value="<%=dblNum1%>"><br>
NUM2: <input type="text" name="num2" value="<%=dblNum2%>"><br>
RESULT: <input type="text" name="result" value="<%=dblAnswer%>"><br>
<input type="submit" name="CHOICE" value="Add">
<input type="submit" name="CHOICE" value="Subtract">
<input type="submit" name="CHOICE" value="Multiply">
<input type="submit" name="CHOICE" value="Divide">
</form>
</body>
</html>
-dlbjr

invariable unerring alien
Jul 19 '05 #3
yeah, that's what I want, except each text field is filled with 0 before the
user enters any number. Any workarounds on that??

"Ray at home" <myfirstname at lane 34 . komm> wrote in message
news:e#**************@TK2MSFTNGP11.phx.gbl...
If you want the result to be in the text field for the result, you have to
write the result into the value of that form element as such.
<%
Dim num1, num2, result
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))
result = num1 + num2
%>

<html>
<body>
<Form action="calc.asp" method="post" name="calc">
<P>NUM1: <input type="text" name="num1" value="<%=num1%>">
<P>NUM2: <input type="text" name="num2" value="<%=num2%>">
<P>RESULT: <input type="text" name="result" value="<%=result%>">
<P><input type="submit">
</Form>


</body>
</html>

Ray at home


"John Davis" <jr*******@hotmail.com> wrote in message
news:#A**************@TK2MSFTNGP12.phx.gbl...
<html>
<body>
<Form action="calc.asp" method="post" name="calc">
<P>NUM1: <input type="text" name="num1">
<P>NUM2: <input type="text" name="num2">
<P>RESULT: <input type="text" name="result">
<P><input type="submit">
</Form>

I want to write an ASP page to accept 2 numbers, and return the sum on the same page. Can we do it in pure ASP without JavaScript?? It sounds an easy problem, and I did that in ASP.NET and JavaScript, but failed in pure ASP 3.0. Here's the attempts, but definitely not what I want because I want

the
result back to the text field.

<%
Dim num1, num2, result
num1 = CInt(Request.Form("num1"))
num2 = CInt(Request.Form("num2"))
result = num1 + num2
Response.Write("<P>Num1 = " & num1)
Response.Write("<P>Num2 = " & num2)
Response.Write("<P>Num3 = " & result)
%>
</body>
</html>


Jul 19 '05 #4
Just detect if the form has been posted or not.

<%
If UCase(Request.ServerVariables("Request_Method")) = "POST" then

intNum1 = Request.Form("txtNumber1")
intNum2 = Request.Form("txtNumber2")

intTotal = intNum1 + intNum2

Else

intNum1 = 0
intNum2 = 0

End If
%>
<html>
<head>
</head>
<body>
<form method="post">
<input type="text" name="txtNumber1" value="<%=intNum1%>"><br>
<input type="text" name="txtNumber2" value="<%=intNum2%>"><br>
<input type="submit">
</form>

<p>
The total is: <%=intTotal%>
</p>
</body>
</html>


"John Davis" <jr*******@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP12.phx.gbl...
: yeah, that's what I want, except each text field is filled with 0 before
the
: user enters any number. Any workarounds on that??
:
: "Ray at home" <myfirstname at lane 34 . komm> wrote in message
: news:e#**************@TK2MSFTNGP11.phx.gbl...
: > If you want the result to be in the text field for the result, you have
to
: > write the result into the value of that form element as such.
: >
: >
: > <%
: > Dim num1, num2, result
: > num1 = CInt(Request.Form("num1"))
: > num2 = CInt(Request.Form("num2"))
: > result = num1 + num2
: > %>
: >
: > <html>
: > <body>
: > <Form action="calc.asp" method="post" name="calc">
: > <P>NUM1: <input type="text" name="num1" value="<%=num1%>">
: > <P>NUM2: <input type="text" name="num2" value="<%=num2%>">
: > <P>RESULT: <input type="text" name="result" value="<%=result%>">
: > <P><input type="submit">
: > </Form>
: >
: >
: >
: >
: > </body>
: > </html>
: >
: > Ray at home
: >
: >
: >
: >
: > "John Davis" <jr*******@hotmail.com> wrote in message
: > news:#A**************@TK2MSFTNGP12.phx.gbl...
: > > <html>
: > > <body>
: > > <Form action="calc.asp" method="post" name="calc">
: > > <P>NUM1: <input type="text" name="num1">
: > > <P>NUM2: <input type="text" name="num2">
: > > <P>RESULT: <input type="text" name="result">
: > > <P><input type="submit">
: > > </Form>
: > >
: > > I want to write an ASP page to accept 2 numbers, and return the sum on
: the
: > > same page. Can we do it in pure ASP without JavaScript?? It sounds an
: easy
: > > problem, and I did that in ASP.NET and JavaScript, but failed in pure
: ASP
: > > 3.0. Here's the attempts, but definitely not what I want because I
want
: > the
: > > result back to the text field.
: > >
: > > <%
: > > Dim num1, num2, result
: > > num1 = CInt(Request.Form("num1"))
: > > num2 = CInt(Request.Form("num2"))
: > > result = num1 + num2
: > > Response.Write("<P>Num1 = " & num1)
: > > Response.Write("<P>Num2 = " & num2)
: > > Response.Write("<P>Num3 = " & result)
: > > %>
: > >
: > >
: > > </body>
: > > </html>
: > >
: > >
: >
: >
:
:
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: brendan | last post by:
Sorry this isnt a cross post .. i just didnt get any help from alt.php. I have a website which utilises post forms for navigation in some areas. Problem is, when *some* users hit the BACK button...
5
by: Jan Roland Eriksson | last post by:
Some more fine tuning and inclusion of last suggested text from regulars has been done to this test post #4 of the mFAQ. As usual, rip it up anywhere you feel that it's appropriate to do so. ...
7
by: Eric | last post by:
I am certain the answer will be 'NO', but I wanted to ask anyway just incase I have missed something. Everyone knows that one pass data to a page in an anchor tag by using the GET Method: <a...
4
by: James Johnson | last post by:
Dear C#Dex, I am trying to automate a POST to a web page that clicks a button. I have been able to hit a target web page and run the web page. However, the button on the page does not click. ...
1
by: Beryl Small | last post by:
Okay, I have a third party (Macromedia Authorware ) software passing a student I.D. number to an ASP page for verification against an SQL database. Authorware uses something like the following:...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
9
by: Alan Silver | last post by:
Hello, From my limited experience with ASP.NET (couple of weeks so far, much time wasted with stupid book), you can only have one form per page. If so, how do you handle the scenario where you...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.