If statement confusion

D

Drew

I have an app that I am building that takes user input on 1 page then
inserts/updates it on the next page. There are a total of 20 pages, with
data from page1 being modified by page2 and so on. I am trying to figure
out how to incorporate back buttons into this app, so the user can go back.
Currently I have tried many different ways to do this (short of re-writing
the pages to submit to themselves and then redirecting). The current train
of thought I am working off of is below,

Page2.asp

Input boxes and 2 buttons, Submit for going to the next page and submit1 for
going back

Page3.asp

'Check to see if the record needs to be inserted or updated
If rsWhatPeopleLike.EOF AND rsWhatPeopleLike.BOF Then

'Check to see if the Back button was clicked
'If so, redirect after modification
If Request.Form("submit1") <> "" Then

'Must have clicked Back, so insert and redirect
'insert code
Response.Redirect("Page1.asp")

Else

'Must have clicked Forward, so insert and go on
'insert code

End If

Else

'Check to see if the Back button was clicked
'If so, redirect after modification
If Request.Form("submit1") <> "" Then

'Check to see if the form fields were edited, if so Update the db
If Request.Form("PeopleLikeAndAdmire") <>
rsWhatPeopleLike("WhatPeopleLikeAndAdmire") Then

'Must have clicked Back, so update and redirect
'update code
Response.Redirect("Page1.asp")

Else

'Must have clicked Forward, so update and go on
'update code

End If

End If

End If

So the user clicks Forward on Page2.asp, then the code should just update or
insert (depending on whether there is a record in the db and if the record
is different than the data entered on page1.asp)

If the user clicks Back, it should alost update or insert and then redirect
back to page1.asp

Can anyone help me out with this? Or if you have a better idea on how to
accomplish this, I am open to suggestions!

Thanks,
Drew
 
D

Drew

Let me rephrase... Not the back button of the browser, but a submit button
named submit1 that has a caption of Back.

Sorry
Drew
 
D

Drew

Pretty much. My conditional isn't working correctly and that is the
problem. Sorry that you are having to dredge this info out of me, I just
failed to mention it.

I am working on doing some testing on the conditional, I will reply when I
figure out what it is doing wrong (besides not working).

Drew
 
D

Drew

The conditionals are setup like this,

After page2.asp is submitted it goes to page3.asp

recordset code for checking to see if the record is available

If rs.EOF AND rs.BOF Then (If the rs is empty, then that means that the
record needs to be inserted)
Insert Code
Else
Update Code
End If

But then I added another button to page2.asp which is named submit1 and
captioned "Back", so if it is clicked, I want the data to be
inserted/updated (determined by the above conditional) and then redirect to
page1.asp

If Request.Form("submit1") <> "" Then (If submit1 was clicked)
Insert Code
Response.Redirect

How can I combine these 2 conditionals in one?

This doesn't seem to work,

If rs.EOF AND rs.BOF Then (If the rs is empty, then that means that the
record needs to be inserted)
If Request.Form("submit1") <> "" Then (If submit1 was clicked)
Insert Code
Response.Redirect
Else
Insert Code
End If
Else
If Request.Form("submit1") <> "" Then (If submit1 was clicked)
Update Code
Response.Redirect
Else
Update Code
End If
End If

Thanks,
Drew
 
J

Jeff Cochran

The conditionals are setup like this,

After page2.asp is submitted it goes to page3.asp

recordset code for checking to see if the record is available

If rs.EOF AND rs.BOF Then (If the rs is empty, then that means that the
record needs to be inserted)
Insert Code
Else
Update Code
End If

But then I added another button to page2.asp which is named submit1 and
captioned "Back", so if it is clicked, I want the data to be
inserted/updated (determined by the above conditional) and then redirect to
page1.asp

If Request.Form("submit1") <> "" Then (If submit1 was clicked)
Insert Code
Response.Redirect

How can I combine these 2 conditionals in one?

Which two conditionals? You have a single one here, if the submit to
the form came from page 2.
This doesn't seem to work,

"Doesn't seem to work" how? Does it cause the workstation to burst
into flames? Or does it simply not behave as you expect? And what
would that behavior be? Versus what did you expect?

Jeff
 
D

Drew

The conditionals are setup like this,
Above is the first conditional

Above is the second conditional
Which two conditionals? You have a single one here, if the submit to
the form came from page 2.

I have commented above so that you can see that there are 2 conditionals...
must have overlooked them, huh? Before we go on, 1 + 1 = 2, right?
"Doesn't seem to work" how? Does it cause the workstation to burst
into flames? Or does it simply not behave as you expect? And what
would that behavior be? Versus what did you expect?

If I click the back button (submit1, not the actual back button), the page
doesn't redirect like it should.

Below is the 2 conditionals from above (1+1 is still 2, right?) combined
together, and this is how I have them in the page.

Thanks,
Drew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top