p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asptoday_discuss thread: displaying result of calculation in the same window


Message #1 by "Tan Chye Ting" <chyeting18@h...> on Wed, 16 Jan 2002 13:33:00
i'm trying to display my result of calculation in the same window as i 

input my variable..how should i do it?thank you
Message #2 by Dragos Tudose <dtudose@y...> on Wed, 16 Jan 2002 12:03:51 -0800 (PST)

here's an ideea..don't know if it'll work..but i think

u can try it



try and set a flag variable which u set on true when u



submit the page

u submit the page to itself..like if the page is calld

asp_page.asp...u submit it like asp_page.asp&flag=true



in the beginning of the page test if the flag is true



if it is display also the result...

if it's false display only the field in which u

request the client the input



__________________________________________________

Do You Yahoo!?

Send FREE video emails in Yahoo! Mail!

http://promo.yahoo.com/videomail/

Message #3 by "Laurence Flello" <info@i...> on Wed, 16 Jan 2002 20:11:58
> i'm trying to display my result of calculation in the same window as i 

> input my variable..how should i do it?thank you



hi

This is quite easy.

you need to append the url of the page and use a select case to trap it.



ie

query = request.querystring("myquery")

request.form variables picked up here

'example your page is mynet.asp

'append form post to mynet.asp?myquery=1



Make your form and post it back to mynet.asp?myquery=1

'this is the equivelant to a post back form keeping in the same page

'its called a recursive form see one at www.tjw.co.uk that i worked on

'put your form into the selct case

ie

select case query

case ""

put the form elements here for first time page load

case 1 'picks up the url with myquery=1

put your response.write statements here from the form collection

its like now you see the form and then you don't on the same page

if you need more info next time i will write a complete page for you to 

look at if needed

good luck laurence

Message #4 by "Tan Chye Ting" <chyeting18@h...> on Thu, 17 Jan 2002 01:49:00
hi, if you don't mind could you please write a complete page for 

me..another question,how do i initialize my textbox to a initial value?

thank you laurence



> > i'm trying to display my result of calculation in the same window as i 

> > input my variable..how should i do it?thank you

> 

> hi

> This is quite easy.

> you need to append the url of the page and use a select case to trap it.

> 

> ie

> query = request.querystring("myquery")

> request.form variables picked up here

> 'example your page is mynet.asp

> 'append form post to mynet.asp?myquery=1

> 

> Make your form and post it back to mynet.asp?myquery=1

> 'this is the equivelant to a post back form keeping in the same page

> 'its called a recursive form see one at www.tjw.co.uk that i worked on

> 'put your form into the selct case

> ie

> select case query

> case ""

> put the form elements here for first time page load

> case 1 'picks up the url with myquery=1

> put your response.write statements here from the form collection

> its like now you see the form and then you don't on the same page

> if you need more info next time i will write a complete page for you to 

> look at if needed

> good luck laurence

Message #5 by "Laurence Flello" <info@i...> on Thu, 17 Jan 2002 17:58:16
> hi, if you don't mind could you please write a complete page for 

> me..another question,how do i initialize my textbox to a initial value?

> thank you laurence

> 

>

Hi

here is the first page. save it as count.asp.

It will give you an idea as to how it works and also the in line tag

as follows for a text field

There is no error checking on the page so make sure you fill in

the first 2 fields. I will write another page where the form comes in

on page load but disappears and writes the answer in asp elsewhere

on the form.Copy and paste this code in total then run it against your

server.it works on mine but if you have any problems come back to me.

next page will be sent today i hope. There is no query string in this page 

that will follow later as an example

good luck

Laurence



 <%

' get the info for recursive form

dim add1, add2, total, total1, query1 

add1 = request.form("firstnum")

add2 = request.form("secondnum")

total1 = request.form("total")

'convert to integar values or another value if you wish

a = CInt(add1)

b = CInt(add2)

total1 = CInt(total1)

total1 = a + b  'get the total

query1 = request.querystring("queryvalue")

'these are the values back from the form

'and query string



%>

<html>



<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>Recursive form</title>

</head>



<body>



<p><font size="5">Recursive form test </font>( Laurence 

Flello ...iisql.net )<br>

simple form testing.</p>



<p>&nbsp;</p>

<form method="POST" action="count.asp">

  

  <p>1st value <input type="text" name="firstnum" size="8"> 2nd value 

<input type="text" name="secondnum" size="7">&nbsp;

  Total&nbsp; <input type="text" name="total" size="20" value= <% = total1 

%>></p>

  <p><input type="submit" value="Add values"></p>

</form>



  

  <p>&nbsp;</p>





<p>Values must be tested in 1st value and 2nd value as you<br>

cannot convert to integar type with an empty string as<br>

this will return an error page telling you, so you must place<br>

values in the first 2 fields.</p>





</body>



</html>

Message #6 by "Laurence Flello" <info@i...> on Thu, 17 Jan 2002 18:44:12
> hi, if you don't mind could you please write a complete page for 

> me..another question,how do i initialize my textbox to a initial value?

> thank you laurence

> 

Hi again

here is the other page.

same rules as before ie no error checking done.

save this page as countmore.asp

the page loads the form and when it comes back after processing

the form disappears and the answer is written out elsewhere.

use the code and your imagination to run in-line code etc





<%

' get the info for recursive form

dim add1, add2, total, total1, query1 

add1 = request.form("firstnum")

add2 = request.form("secondnum")

total1 = request.form("total")

'convert to integar values or another value if you wish

a = CInt(add1)

b = CInt(add2)

total1 = CInt(total1)

total1 = a + b  'get the total

query1 = request.querystring("queryvalue")

'these are the values back from the form

'and query string



%>

<html>



<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>Recursive form</title>

</head>



<body>



<p><font size="5">Recursive form test </font>( Laurence 

Flello ...iisql.net )<br>

simple form testing.</p>



<p>&nbsp;</p>

<%

select case query1

case ""

response.write "<form method='POST' action='countmore.asp?queryvalue=1'>" 

& _

  

  "<p>1st value <input type='text' name='firstnum' size='8'> 2nd value 

<input type='text' name='secondnum' size='7'>&nbsp;" & _

  "Total&nbsp; <input type='text' name='total' size='20' value=" & total1 

& "></p>" & _

  "<p><input type='submit' value='Add values'></p>" & _

"</form>"

response.write "<p>Values must be tested in 1st value and 2nd value as 

you<br>" & _

"cannot convert to integar type with an empty string as<br>" & _

"this will return an error page telling you, so you must place<br>" & _

"values in the first 2 fields.</p>" 

case "1"

response.write "<font size='5'>The answer is : " & total1 & "</font>" & _

"<p><font size='3'><b>Return to the form <a 

href='countmore.asp'>here</a></b></font></p>"

end select

%>

  

  <p>&nbsp;</p>

</body>



</html>

good luck

Laurence

  Return to Index