Page redirect

Results 1 to 3 of 3

Thread: Page redirect

  1. #1
    Join Date
    Dec 1969

    Default Page redirect

    On my save page, I have the following code. It seems to work fine except for one thing. When one of the form fields is not filled it goes back to the form and form is all empty. It&#039;s a huge form and I would like to show the data that users has alredy enterd. How is it possible??<BR><BR>Thanks<BR><BR><BR>For each Item in Request.Form<BR> If Item &#060;&#062;"" AND Item &#060;&#062; "Submit" Then<BR> rs.fields(Item) = Request.Form(Item)<BR> Else<BR> response.redirect("questionnaire.asp")<BR> End If<BR>Next<BR>

  2. #2
    Join Date
    Dec 1969

    Default Well, you've got yourself..

    .. a problem.<BR><BR>It&#039;s doing what you tell it. Just go to questionnaire.asp. You didn&#039;t tell it to retrieve the values. And, more so, how do you know what those values are?<BR><BR>So, you have 2 options.<BR><BR>1) Put this code into an IF statement on questionnaire.asp:<BR>If Request.QueryString("a") = "frm" Then<BR> ... handle form submit ...<BR>Dim ErrorOccured<BR> ErrorOccured = False<BR><BR> For each Item in Request.Form<BR> If Item &#060;&#062;"" AND Item &#060;&#062; "Submit" Then<BR> rs.fields(Item) = Request.Form(Item)<BR> Else<BR> bErrorOccured = True<BR> End If<BR> Next<BR><BR> If ErrorOccured Then<BR> Rs.Close<BR> Else<BR> Rs.Update<BR> Rs.Close<BR> End If<BR><BR> If ErrorOccured = False Then<BR> Response.Redirect "Questionnaire_Complete.asp"<BR> End If<BR><BR>End If<BR><BR>And, on your form, you have to setup EACH field to be prepopulated:<BR>&#060;input type="text" name="happyDance" value="&#060;%=Server.HTMLEncode(Request.Form("hap pyDance")) %&#062;" /&#062;<BR><BR>Or, your other option is to put all of the Request.Form elements into Session variables. And use those Session variables to prepopulate the form.<BR><BR>Or, go to ASP.NET. It does this kind of thing for you.

  3. #3
    Join Date
    Dec 1969

    Default Four ways

    One: Step through the form collection and build a string of the form item names and values.. Tack these on to the end of the query string. Parse the query string to get back the responses.<BR><BR>Two: Step through the form collection and put each one into a session variable. Use those to populate the form.<BR><BR>Three: Use the same page as the target, and if you need to redisplay the form, then request the values back out.<BR><BR>Four: Don&#039;t use redirect. Use server.transfer and transfer back to the questionaire.asp. In the questionaire.asp use Request.form to populate the form input values.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts