Help with passing form field values.

Discussion in 'ASP General' started by Brave, Dec 3, 2009.

  1. Brave

    Brave Guest

    I currently use the following to redirect to an error page if a
    certain form field is not filled out.

    If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    ("FORM_FIELD_2") = "" Then
    Response.Redirect("FORM_ERROR_PAGE.asp")
    End If

    I have a situation now where I need to submit form data to one of two
    pages based on field values.

    Can I use this code to submit form data to one of two pages? I do not
    know the proper code, but something like

    If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    ("FORM_FIELD_2") = "" Then
    SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    End If


    Any sample code to solve my problem would be a huge help.

    Thanks for your time.
     
    Brave, Dec 3, 2009
    #1
    1. Advertising

  2. Brave

    Evertjan. Guest

    Brave wrote on 03 dec 2009 in microsoft.public.inetserver.asp.general:

    > I currently use the following to redirect to an error page if a
    > certain form field is not filled out.
    >
    > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > ("FORM_FIELD_2") = "" Then
    > Response.Redirect("FORM_ERROR_PAGE.asp")
    > End If
    >
    > I have a situation now where I need to submit form data to one of two
    > pages based on field values.
    >
    > Can I use this code to submit form data to one of two pages? I do not
    > know the proper code, but something like
    >
    > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > ("FORM_FIELD_2") = "" Then
    > SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    > End If


    You should be already on the submitting page
    where you divert if your standard is not met:

    ============ FORM_PROCESS_PAGE.asp ==================
    If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    ("FORM_FIELD_2") = "" Then
    Response.Redirect("FORM_ERROR_PAGE.asp")
    End If

    --- Do here your form processing ----

    ======================================================



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 3, 2009
    #2
    1. Advertising

  3. Brave

    Brave Guest

    On Dec 3, 11:28 am, "Evertjan." <> wrote:
    > Brave wrote on 03 dec 2009 in microsoft.public.inetserver.asp.general:
    >
    >
    >
    >
    >
    > > I currently use the following to redirect to an error page if a
    > > certain form field is not filled out.

    >
    > > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > > ("FORM_FIELD_2") = "" Then
    > > Response.Redirect("FORM_ERROR_PAGE.asp")
    > > End If

    >
    > > I have a situation now where I need to submit form data to one of two
    > > pages based on field values.

    >
    > > Can I use this code to submit form data to one of two pages? I do not
    > > know the proper code, but something like

    >
    > > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > > ("FORM_FIELD_2") = "" Then
    > > SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    > > End If

    >
    > You should be already on the submitting page
    > where you divert if your standard is not met:
    >
    > ============ FORM_PROCESS_PAGE.asp ==================
    > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >   ("FORM_FIELD_2") = "" Then
    >      Response.Redirect("FORM_ERROR_PAGE.asp")
    > End If
    >
    > --- Do here your form processing ----
    >
    > ======================================================
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)- Hide quoted text -
    >
    > - Show quoted text -


    Although I can redirect to the page, it does not pass thr form values
    over. I need to basically "Submit" the form to a page that determines
    based on a field value which page will "process" the form.

    Example: If the form field value equals yes, then go to a page that
    drops the data into a database.
    If the form field equals no, thren go tp a page that
    drops the data into an email.

    I can move from page to page with no problem, but the form values ar
    not comming with me on the redirect option.

    It there something other than redirect that is used to "Submit" data
    to a page?
     
    Brave, Dec 3, 2009
    #3
  4. Brave

    Evertjan. Guest

    Brave wrote on 03 dec 2009 in microsoft.public.inetserver.asp.general:

    > On Dec 3, 11:28 am, "Evertjan." <> wrote:
    >> Brave wrote on 03 dec 2009 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >>
    >>
    >>
    >>
    >> > I currently use the following to redirect to an error page if a
    >> > certain form field is not filled out.

    >>
    >> > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >> > ("FORM_FIELD_2") = "" Then
    >> > Response.Redirect("FORM_ERROR_PAGE.asp")
    >> > End If

    >>
    >> > I have a situation now where I need to submit form data to one of
    >> > two pages based on field values.

    >>
    >> > Can I use this code to submit form data to one of two pages? I do
    >> > not know the proper code, but something like

    >>
    >> > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >> > ("FORM_FIELD_2") = "" Then
    >> > SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    >> > End If

    >>
    >> You should be already on the submitting page
    >> where you divert if your standard is not met:
    >>
    >> ============ FORM_PROCESS_PAGE.asp ====

    > =============> If Request.Form("FORM_FIELD_1") = "Yes" AND
    > Request.Form
    >>   ("FORM_FIELD_2") = "" Then
    >>      Response.Redirect("FORM_ERROR_PAGE.asp")
    >> End If
    >>
    >> --- Do here your form processing ----
    >>
    >> ========================

    > =============================>


    [please do not quote signatures on usenet]

    -
    >>
    >> - Show quoted text -

    >
    > Although I can redirect to the page, it does not pass thr form values
    > over. I need to basically "Submit" the form to a page that determines
    > based on a field value which page will "process" the form.


    You do not need to redirect to the page, you just add your redirecting
    code in the top of the form processing page.

    > Example: If the form field value equals yes, then go to a page that
    > drops the data into a database.
    > If the form field equals no, thren go tp a page that
    > drops the data into an email.


    that's fine, but why would you neeed two pages,
    ypu can do that all in one page.

    ============ FORM_PROCESS_PAGE.asp ====
    If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
      ("FORM_FIELD_2") = "" Then
         Response.Redirect("FORM_ERROR_PAGE.asp")
    Elseif Request.Form("FORM_FIELD_1") = "Yes" Then
    --- drop the data into a database ---
    Else
    --- drop the data into an email ---
    End If
    ========================

    > I can move from page to page with no problem, but the form values ar
    > not comming with me on the redirect option.


    No, of course you could make a clientside hidden[?] form containing the
    data to be resubmitted, but there is no reason to give hackers this
    extra possibility to hack.

    What is wrong with doing it on the same page?

    > It there something other than redirect that is used to "Submit" data
    > to a page?


    Submission is a clientside happening.

    Redirection can only do querystring submission,
    post/form submission is not possible in a redirect that way,
    as you could deduce for your self.

    so there are 3 [sensible] ways of using post submitted data on the
    server:

    1 use the request.form data on the same page

    or

    2 keep the data on the server in session variables for use on another
    page

    or

    3 keep the data on the server in a database for use on another page


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 3, 2009
    #4
  5. Brave

    Brave Guest

    On Dec 3, 12:37 pm, "Evertjan." <> wrote:
    > Brave wrote on 03 dec 2009 in microsoft.public.inetserver.asp.general:
    >
    >
    >
    >
    >
    > > On Dec 3, 11:28 am, "Evertjan." <> wrote:
    > >> Brave wrote on 03 dec 2009 in
    > >> microsoft.public.inetserver.asp.general:

    >
    > >> > I currently use the following to redirect to an error page if a
    > >> > certain form field is not filled out.

    >
    > >> > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > >> > ("FORM_FIELD_2") = "" Then
    > >> > Response.Redirect("FORM_ERROR_PAGE.asp")
    > >> > End If

    >
    > >> > I have a situation now where I need to submit form data to one of
    > >> > two pages based on field values.

    >
    > >> > Can I use this code to submit form data to one of two pages? I do
    > >> > not know the proper code, but something like

    >
    > >> > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    > >> > ("FORM_FIELD_2") = "" Then
    > >> > SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    > >> > End If

    >
    > >> You should be already on the submitting page
    > >> where you divert if your standard is not met:

    >
    > >> ============ FORM_PROCESS_PAGE.asp ====

    > > =============> If Request.Form("FORM_FIELD_1") = "Yes" AND
    > > Request.Form
    > >>   ("FORM_FIELD_2") = "" Then
    > >>      Response.Redirect("FORM_ERROR_PAGE.asp")
    > >> End If

    >
    > >> --- Do here your form processing ----

    >
    > >> ========================

    > > =============================>

    >
    > [please do not quote signatures on usenet]
    >
    > -
    >
    >
    >
    > >> - Show quoted text -

    >
    > > Although I can redirect to the page, it does not pass thr form values
    > > over. I need to basically "Submit" the form to a page that determines
    > > based on a field value which page will "process" the form.

    >
    > You do not need to redirect to the page, you just add your redirecting
    > code in the top of the form processing page.
    >
    > > Example: If the form field value equals yes, then go to a page that
    > > drops the data into a database.
    > >               If the form field equals no, thren go tp a page that
    > > drops the data into an email.

    >
    > that's fine, but why would you neeed two pages,
    > ypu can do that all in one page.
    >
    > ============ FORM_PROCESS_PAGE.asp ====
    > If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >    ("FORM_FIELD_2") = "" Then
    >       Response.Redirect("FORM_ERROR_PAGE.asp")
    > Elseif Request.Form("FORM_FIELD_1") = "Yes" Then
    >  --- drop the data into a database ---
    > Else
    >  --- drop the data into an email ---
    > End If
    > ========================
    >
    > > I can move from page to page with no problem, but the form values ar
    > > not comming with me on the redirect option.

    >
    > No, of course you could make a clientside hidden[?] form containing the
    > data to be resubmitted, but there is no reason to give hackers this
    > extra possibility to hack.
    >
    > What is wrong with doing it on the same page?
    >
    > > It there something other than redirect that is used to "Submit" data
    > > to a page?

    >
    > Submission is a clientside happening.
    >
    > Redirection can only do querystring submission,
    > post/form submission is not possible in a redirect that way,
    > as you could deduce for your self.
    >
    > so there are 3 [sensible] ways of using post submitted data on the
    > server:
    >
    > 1 use the request.form data on the same page
    >
    > or
    >
    > 2 keep the data on the server in session variables for use on another
    > page
    >
    > or
    >
    > 3 keep the data on the server in a database for use on another page
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)- Hide quoted text -
    >
    > - Show quoted text -


    Ok, I'm not explaining it well so lets go this route.

    I have a form that gathers some personal info such as name, email, and
    street address.

    The form has a field that is a radio button with the options of "Yes"
    ot "No"

    If they choose "Yes", I need to send the existing values to a new form
    with 10 additional fields.

    If they choose "No", I will need to send the existing values to a
    completely different form with added fields that have nothing to do
    with the version they use if they choose yes.

    So what I need is a way to submit a form to a page that makes the
    determination of which form we will be sendiong the data to based on
    the Yes/No field.

    Can this be done?
     
    Brave, Dec 3, 2009
    #5
  6. Brave

    Bob Barrows Guest

    Brave wrote:
    >
    > Ok, I'm not explaining it well so lets go this route.
    >
    > I have a form that gathers some personal info such as name, email, and
    > street address.
    >
    > The form has a field that is a radio button with the options of "Yes"
    > ot "No"
    >
    > If they choose "Yes", I need to send the existing values to a new form
    > with 10 additional fields.
    >
    > If they choose "No", I will need to send the existing values to a
    > completely different form with added fields that have nothing to do
    > with the version they use if they choose yes.
    >
    > So what I need is a way to submit a form to a page that makes the
    > determination of which form we will be sendiong the data to based on
    > the Yes/No field.
    >
    > Can this be done?


    Yes:
    a. you can use client-side code in the radio element's on_click event to
    change the action attribute of the form element
    b. In server-side code, you can use Server.Transfer to transfer the
    request to a different page.
    --
    HTH,
    Bob Barrows
     
    Bob Barrows, Dec 3, 2009
    #6
  7. Brave

    Neil Gould Guest

    Brave wrote:
    > On Dec 3, 12:37 pm, "Evertjan." <> wrote:
    >> Brave wrote on 03 dec 2009 in
    >> microsoft.public.inetserver.asp.general:
    >>
    >>
    >>
    >>
    >>
    >>> On Dec 3, 11:28 am, "Evertjan." <>
    >>> wrote:
    >>>> Brave wrote on 03 dec 2009 in
    >>>> microsoft.public.inetserver.asp.general:

    >>
    >>>>> I currently use the following to redirect to an error page if a
    >>>>> certain form field is not filled out.

    >>
    >>>>> If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >>>>> ("FORM_FIELD_2") = "" Then
    >>>>> Response.Redirect("FORM_ERROR_PAGE.asp")
    >>>>> End If

    >>
    >>>>> I have a situation now where I need to submit form data to one of
    >>>>> two pages based on field values.

    >>
    >>>>> Can I use this code to submit form data to one of two pages? I do
    >>>>> not know the proper code, but something like

    >>
    >>>>> If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >>>>> ("FORM_FIELD_2") = "" Then
    >>>>> SUBMIT_TO("FORM_PROCESS_PAGE.asp")
    >>>>> End If

    >>
    >>>> You should be already on the submitting page
    >>>> where you divert if your standard is not met:

    >>
    >>>> ============ FORM_PROCESS_PAGE.asp ====
    >>> =============> If Request.Form("FORM_FIELD_1") = "Yes" AND
    >>> Request.Form
    >>>> ("FORM_FIELD_2") = "" Then
    >>>> Response.Redirect("FORM_ERROR_PAGE.asp")
    >>>> End If

    >>
    >>>> --- Do here your form processing ----

    >>
    >>>> ========================
    >>> =============================>

    >>
    >> [please do not quote signatures on usenet]
    >>
    >> -
    >>
    >>
    >>
    >>>> - Show quoted text -

    >>
    >>> Although I can redirect to the page, it does not pass thr form
    >>> values over. I need to basically "Submit" the form to a page that
    >>> determines based on a field value which page will "process" the
    >>> form.

    >>
    >> You do not need to redirect to the page, you just add your
    >> redirecting code in the top of the form processing page.
    >>
    >>> Example: If the form field value equals yes, then go to a page that
    >>> drops the data into a database.
    >>> If the form field equals no, thren go tp a page that
    >>> drops the data into an email.

    >>
    >> that's fine, but why would you neeed two pages,
    >> ypu can do that all in one page.
    >>
    >> ============ FORM_PROCESS_PAGE.asp ====
    >> If Request.Form("FORM_FIELD_1") = "Yes" AND Request.Form
    >> ("FORM_FIELD_2") = "" Then
    >> Response.Redirect("FORM_ERROR_PAGE.asp")
    >> Elseif Request.Form("FORM_FIELD_1") = "Yes" Then
    >> --- drop the data into a database ---
    >> Else
    >> --- drop the data into an email ---
    >> End If
    >> ========================
    >>
    >>> I can move from page to page with no problem, but the form values ar
    >>> not comming with me on the redirect option.

    >>
    >> No, of course you could make a clientside hidden[?] form containing
    >> the data to be resubmitted, but there is no reason to give hackers
    >> this extra possibility to hack.
    >>
    >> What is wrong with doing it on the same page?
    >>
    >>> It there something other than redirect that is used to "Submit" data
    >>> to a page?

    >>
    >> Submission is a clientside happening.
    >>
    >> Redirection can only do querystring submission,
    >> post/form submission is not possible in a redirect that way,
    >> as you could deduce for your self.
    >>
    >> so there are 3 [sensible] ways of using post submitted data on the
    >> server:
    >>
    >> 1 use the request.form data on the same page
    >>
    >> or
    >>
    >> 2 keep the data on the server in session variables for use on another
    >> page
    >>
    >> or
    >>
    >> 3 keep the data on the server in a database for use on another page
    >>
    >> --
    >> Evertjan.
    >> The Netherlands.
    >> (Please change the x'es to dots in my emailaddress)- Hide quoted
    >> text -
    >>
    >> - Show quoted text -

    >
    > Ok, I'm not explaining it well so lets go this route.
    >
    > I have a form that gathers some personal info such as name, email, and
    > street address.
    >
    > The form has a field that is a radio button with the options of "Yes"
    > ot "No"
    >
    > If they choose "Yes", I need to send the existing values to a new form
    > with 10 additional fields.
    >
    > If they choose "No", I will need to send the existing values to a
    > completely different form with added fields that have nothing to do
    > with the version they use if they choose yes.
    >
    > So what I need is a way to submit a form to a page that makes the
    > determination of which form we will be sendiong the data to based on
    > the Yes/No field.
    >
    > Can this be done?
    >

    When I need to do this kind of thing, I use session variables to store the
    collected data. For example, if each of 3 forms have 10 fields, 30 session
    variables would be needed. One advantage to this approach is that, should
    there be a need for the user to make corrections, previous form pages can be
    populated with the session variable information and a summary of the
    submissions is also easy to accomplish.

    Best,

    Neil
     
    Neil Gould, Dec 3, 2009
    #7
  8. Brave

    Evertjan. Guest

    Brave wrote on 03 dec 2009 in microsoft.public.inetserver.asp.general:

    > Ok, I'm not explaining it well so lets go this route.
    >
    > I have a form that gathers some personal info such as name, email, and
    > street address.
    >
    > The form has a field that is a radio button with the options of "Yes"
    > ot "No"
    >
    > If they choose "Yes", I need to send the existing values to a new form
    > with 10 additional fields.
    >
    > If they choose "No", I will need to send the existing values to a
    > completely different form with added fields that have nothing to do
    > with the version they use if they choose yes.
    >
    > So what I need is a way to submit a form to a page that makes the
    > determination of which form we will be sendiong the data to based on
    > the Yes/No field.
    >
    > Can this be done?
    >


    As I told you, in my view it is better to use one page,
    and make the additional values visible bij clientside scripting,
    submitting all data in one go.

    BUT,

    if you want to do this in separate files, you can choose to keep the
    primary data on the server in session variables.

    OR

    Populate the primary data in hidden input's on the client, like:

    <input type='hidden' name='primary' value='<% = thePrimaryValue %>'>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Dec 3, 2009
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Dixson
    Replies:
    1
    Views:
    530
    Joe Fallon
    May 18, 2004
  2. NotGiven
    Replies:
    3
    Views:
    376
    Michael D. Kersey
    May 13, 2004
  3. GavMc
    Replies:
    4
    Views:
    366
    Evertjan.
    Sep 22, 2005
  4. NotGiven
    Replies:
    3
    Views:
    321
    Michael D. Kersey
    May 13, 2004
  5. Jaygo
    Replies:
    2
    Views:
    141
    Jaygo
    Jun 24, 2004
Loading...

Share This Page