Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional submit

Status
Not open for further replies.

JonathanG6SWJ

Programmer
Jan 18, 2005
39
GB
Hi Guys

Is there a way I can submit a page from within asp code -
for example> if x then submit page.

I think I've already got some of the pieces of the jigsaw.
Suspect I need to used a javascript function and call that when the condition is met.

Many thanks in advance
Jonathan
 
The ASP code runs on the web server but is the client machine's browser that submits a form.

Are you asking about using client-side script to submit a form?
 
I guess the answers probably both! - but not at the same time :)

In the main I want to be able to go to another page say if I get records back from a DB enquiry triggered from my first page with a submit button. But I also want to be able to have "posted" so I can still use Request.Form("xx").

Hope that makes sense
J
 
So is this what you have in mind?

1. Form is on Page1, submits to Page2

2. Page2 uses Request.Form to query a database

3. Based on the query results, Page2 may redirect the user to Page3

4. Page3 is able to access the query results from Page2 using the Request.Form syntax.
 
I think so!! - I think I've lost my way a little

What I wanted to do was....

A)Start on Page 1 - Intro page with option(submit) buttons.
B)Submit Page1 > Page2. Page 2 is Login page - get user details (+ carry forward option selected on page1)
C)Submit page2 > page3. Page3(no girlies here!!) Validate login details against DB - if successfull goto Page x,y or z depending on what option user selected on page1.

The look / feel of presenting user with options of what they want to do before they login has caused me most of the problems but it is important for the look / feel for it to stay this way.

I think I am going to have to validate user login details on each page x,y &z to allow logic / navigation above to work.

Phew - that explanation hurt my grey matter.

Thanks in advance
J

 
Take a look at Server.Transfer and Response.Redirect. Response.Redirect calls back to the client browser and tells it to go to this other [supplied] address while Server.Transfer transfers operations to thge target page on the server-side (leaving you with access to Request.Form, etc).

-T

barcode_1.gif
 
Tarwn - Thanks for that.

I've got to the stage where once I have validated login details against DB (on "validate.asp") I can successfully server.transfer "newpage.asp". - THANK YOU!

But I am a little confused as to what I can pick up with Request.Form - I can't seem to get any variables from validate.asp.

Regards
J
 
A further update. I can get values from page1 - the option/action the user selected. I cannot get the results from page2 - the results from the DB query.
 
You should be able to access the same Request.Form values that you could from your validate page. Basically when your using Server.Transfer you are still operating from the same Form post that occurred from your login page, so any fields that ghot posted to your valiudate page should still be available to you from the 3rd page that you had Server.Transfer'red to.

One good way to see this in action would be to create an output loop on your last page to output everything in Request.Form to the browser page, something like:
Code:
Dim aFld
For Each aFld in Request.Form
   Response.Write aFld & ": " & Request.Form(aFld) & "<br>"
Next
That will at least show you what your getting on the last page :)

-T

barcode_1.gif
 
Server.Transfer runs the new page using the request header from the old page.

What exactly are you trying to pass between pages? Can you use a session variable perhaps?
 
Hmmmm.... I think its all working exactly as it should but I still can't do what I want. To summarize

Page1 - User selects an action (posted to page2 via submit)
Page2 - User enters login data and submits to Page3 + User action from Page1 via Request.form also submitted
Page3 - Confirm login data with DB query & then server.transfer to pageXX

On page XX I can get access to request.form data same as I could on page 3 BUT I cannot access the results from the DB query on pageXX.

Its like one of those old computer games I used to play when I was at school on the old teleprinter.. I pick up the torch in room one - head east and then pick up a bucket located behind a large rock.... :) I want cumulatively pick up / collect variables along the way to page 4

Once again many,many thanks in advance.
J
 
Wow.. I was typing my response only to find more replies in the mean time... I think I've lost the plot.. It would appear that session variables may well be the way to go but would I be correct in saying they are stored as a cookies.. if so my users will more than likely have cookies disabled....

J
 
Jonathan,

If code is reasonably short...could you show us it using 3
Code:
tages. 1 for page1, 2 page 2 and 3 for page 3
This way the programmers here can SEE your logic and advise accordingly. Thanks.


BSL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top