Request.form usage not clear

Discussion in 'ASP General' started by Jack, Mar 24, 2005.

  1. Jack

    Jack Guest

    Hi,
    I am trying to get a thorough understanding of a code where a addition or
    deletion of records can be done from a list of records. For addition part of
    the form, data is being obtained from set of input boxes.
    The following is the code being used:

    If Len(Request.Form("ID_0"))>0 Then
    AuthorID=Request.Form("ID_0")
    FName=Request.Form("fName_0")
    LName=Request.Form("lName_0")

    ' SQL will break on names like O'Leary
    ' if single quotes are not doubled.
    LName=Replace(LName,"'","''")

    Phone=Request.Form("Phone_0")
    Address=Request.Form("Address_0")
    City=Request.Form("City_0")
    State=Request.Form("State_0")

    ' Create the UPDATE SQL Statement
    sql = " INSERT INTO Authors (au_id, au_fName, "
    sql = sql & "au_lName, phone, address, city, state)"
    sql = sql & " VALUES('" & AuthorID & "','" & FName
    sql = sql & "','" & LName & "','" & Phone
    sql = sql & "','" & Address & "','" & City
    sql = sql & "','" & State & "')"

    ' Execute the INSERT SQL
    cnnPubs.Execute sql
    intCount=1
    End if
    I am not clear where the 0 suffix is coming from in the following:
    AuthorID=Request.Form("ID_0")
    FName=Request.Form("fName_0")

    Thanks for any help.
     
    Jack, Mar 24, 2005
    #1
    1. Advertising

  2. Jack

    Evertjan. Guest

    =?Utf-8?B?SmFjaw==?= wrote on 25 mrt 2005 in
    microsoft.public.inetserver.asp.general:

    > Hi,
    > I am trying to get a thorough understanding of a code where a addition
    > or deletion of records can be done from a list of records. For
    > addition part of the form, data is being obtained from set of input
    > boxes. The following is the code being used:
    >
    > If Len(Request.Form("ID_0"))>0 Then
    > AuthorID=Request.Form("ID_0")
    > FName=Request.Form("fName_0")
    > LName=Request.Form("lName_0")
    >
    > ' SQL will break on names like O'Leary
    > ' if single quotes are not doubled.
    > LName=Replace(LName,"'","''")
    >
    > Phone=Request.Form("Phone_0")
    > Address=Request.Form("Address_0")
    > City=Request.Form("City_0")
    > State=Request.Form("State_0")
    >
    > ' Create the UPDATE SQL Statement
    > sql = " INSERT INTO Authors (au_id, au_fName, "
    > sql = sql & "au_lName, phone, address, city, state)"
    > sql = sql & " VALUES('" & AuthorID & "','" & FName
    > sql = sql & "','" & LName & "','" & Phone
    > sql = sql & "','" & Address & "','" & City
    > sql = sql & "','" & State & "')"
    >
    > ' Execute the INSERT SQL
    > cnnPubs.Execute sql
    > intCount=1
    > End if
    > I am not clear where the 0 suffix is coming from in the following:
    > AuthorID=Request.Form("ID_0")
    > FName=Request.Form("fName_0")


    That is what you typed in, I presume.

    do you have any other suggestions?


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Mar 24, 2005
    #2
    1. Advertising

  3. Jack

    Jack Guest

    Thanks for pointing that out. At a later part of the code, there is indeed
    reference to the 0s. Regards.

    "Evertjan." wrote:

    > =?Utf-8?B?SmFjaw==?= wrote on 25 mrt 2005 in
    > microsoft.public.inetserver.asp.general:
    >
    > > Hi,
    > > I am trying to get a thorough understanding of a code where a addition
    > > or deletion of records can be done from a list of records. For
    > > addition part of the form, data is being obtained from set of input
    > > boxes. The following is the code being used:
    > >
    > > If Len(Request.Form("ID_0"))>0 Then
    > > AuthorID=Request.Form("ID_0")
    > > FName=Request.Form("fName_0")
    > > LName=Request.Form("lName_0")
    > >
    > > ' SQL will break on names like O'Leary
    > > ' if single quotes are not doubled.
    > > LName=Replace(LName,"'","''")
    > >
    > > Phone=Request.Form("Phone_0")
    > > Address=Request.Form("Address_0")
    > > City=Request.Form("City_0")
    > > State=Request.Form("State_0")
    > >
    > > ' Create the UPDATE SQL Statement
    > > sql = " INSERT INTO Authors (au_id, au_fName, "
    > > sql = sql & "au_lName, phone, address, city, state)"
    > > sql = sql & " VALUES('" & AuthorID & "','" & FName
    > > sql = sql & "','" & LName & "','" & Phone
    > > sql = sql & "','" & Address & "','" & City
    > > sql = sql & "','" & State & "')"
    > >
    > > ' Execute the INSERT SQL
    > > cnnPubs.Execute sql
    > > intCount=1
    > > End if
    > > I am not clear where the 0 suffix is coming from in the following:
    > > AuthorID=Request.Form("ID_0")
    > > FName=Request.Form("fName_0")

    >
    > That is what you typed in, I presume.
    >
    > do you have any other suggestions?
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Replace all crosses with dots in my emailaddress)
    >
    >
     
    Jack, Mar 24, 2005
    #3
  4. Jack

    Mark Schupp Guest

    Appending an index number to the field name is one way of keeping track of
    multiple records on a single form.
    For example:

    First author on form would have: ID_0, fname_0, lname_0 ...
    Second author: id_1, fname_1, lname_1

    And so on. Have a look at the code that generates the form and you will
    probably find a loop that creates each set of form fields.

    --
    --Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Jack" <> wrote in message
    news:...
    > Hi,
    > I am trying to get a thorough understanding of a code where a addition or
    > deletion of records can be done from a list of records. For addition part
    > of
    > the form, data is being obtained from set of input boxes.
    > The following is the code being used:
    >
    > If Len(Request.Form("ID_0"))>0 Then
    > AuthorID=Request.Form("ID_0")
    > FName=Request.Form("fName_0")
    > LName=Request.Form("lName_0")
    >
    > ' SQL will break on names like O'Leary
    > ' if single quotes are not doubled.
    > LName=Replace(LName,"'","''")
    >
    > Phone=Request.Form("Phone_0")
    > Address=Request.Form("Address_0")
    > City=Request.Form("City_0")
    > State=Request.Form("State_0")
    >
    > ' Create the UPDATE SQL Statement
    > sql = " INSERT INTO Authors (au_id, au_fName, "
    > sql = sql & "au_lName, phone, address, city, state)"
    > sql = sql & " VALUES('" & AuthorID & "','" & FName
    > sql = sql & "','" & LName & "','" & Phone
    > sql = sql & "','" & Address & "','" & City
    > sql = sql & "','" & State & "')"
    >
    > ' Execute the INSERT SQL
    > cnnPubs.Execute sql
    > intCount=1
    > End if
    > I am not clear where the 0 suffix is coming from in the following:
    > AuthorID=Request.Form("ID_0")
    > FName=Request.Form("fName_0")
    >
    > Thanks for any help.
    >
     
    Mark Schupp, Mar 25, 2005
    #4
  5. Jack

    Jack Guest

    Thanks for the clarity of the concept Mark. I saw later how the code keeps
    track of multiple records in a single form. Is there any way of handling this
    kind of problems? Just curious. Regards.

    "Mark Schupp" wrote:

    > Appending an index number to the field name is one way of keeping track of
    > multiple records on a single form.
    > For example:
    >
    > First author on form would have: ID_0, fname_0, lname_0 ...
    > Second author: id_1, fname_1, lname_1
    >
    > And so on. Have a look at the code that generates the form and you will
    > probably find a loop that creates each set of form fields.
    >
    > --
    > --Mark Schupp
    > Head of Development
    > Integrity eLearning
    > www.ielearning.com
    >
    >
    > "Jack" <> wrote in message
    > news:...
    > > Hi,
    > > I am trying to get a thorough understanding of a code where a addition or
    > > deletion of records can be done from a list of records. For addition part
    > > of
    > > the form, data is being obtained from set of input boxes.
    > > The following is the code being used:
    > >
    > > If Len(Request.Form("ID_0"))>0 Then
    > > AuthorID=Request.Form("ID_0")
    > > FName=Request.Form("fName_0")
    > > LName=Request.Form("lName_0")
    > >
    > > ' SQL will break on names like O'Leary
    > > ' if single quotes are not doubled.
    > > LName=Replace(LName,"'","''")
    > >
    > > Phone=Request.Form("Phone_0")
    > > Address=Request.Form("Address_0")
    > > City=Request.Form("City_0")
    > > State=Request.Form("State_0")
    > >
    > > ' Create the UPDATE SQL Statement
    > > sql = " INSERT INTO Authors (au_id, au_fName, "
    > > sql = sql & "au_lName, phone, address, city, state)"
    > > sql = sql & " VALUES('" & AuthorID & "','" & FName
    > > sql = sql & "','" & LName & "','" & Phone
    > > sql = sql & "','" & Address & "','" & City
    > > sql = sql & "','" & State & "')"
    > >
    > > ' Execute the INSERT SQL
    > > cnnPubs.Execute sql
    > > intCount=1
    > > End if
    > > I am not clear where the 0 suffix is coming from in the following:
    > > AuthorID=Request.Form("ID_0")
    > > FName=Request.Form("fName_0")
    > >
    > > Thanks for any help.
    > >

    >
    >
    >
    >
     
    Jack, Mar 25, 2005
    #5
  6. Jack

    Mark Schupp Guest

    do you mean any "other" way for that kind of problem?

    If you name all of the fields of the same type the same name (ie: "id"
    instead of "id_0", "id_1", ...) then you can use array notation on the
    server to extract the data. Or you can use the split function to break of
    the field data into individual records (when field names are repeated the
    data is sent in a comma separated string).

    Form:

    <input name="id" ....
    <input name="lname" ...
    <input name="id" ....
    <input name="lname" ...
    <input name="id" ....
    <input name="lname" ...

    Script
    For i = 0 to Request.Form("id").Count
    id = Request.Form("id")(i)
    lname=Request.Form("lname")(i)

    ....

    Next

    --
    --Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com

    "Jack" <> wrote in message
    news:...
    > Thanks for the clarity of the concept Mark. I saw later how the code keeps
    > track of multiple records in a single form. Is there any way of handling
    > this
    > kind of problems? Just curious. Regards.
    >
    > "Mark Schupp" wrote:
    >
    >> Appending an index number to the field name is one way of keeping track
    >> of
    >> multiple records on a single form.
    >> For example:
    >>
    >> First author on form would have: ID_0, fname_0, lname_0 ...
    >> Second author: id_1, fname_1, lname_1
    >>
    >> And so on. Have a look at the code that generates the form and you will
    >> probably find a loop that creates each set of form fields.
    >>
    >> --
    >> --Mark Schupp
    >> Head of Development
    >> Integrity eLearning
    >> www.ielearning.com
    >>
    >>
    >> "Jack" <> wrote in message
    >> news:...
    >> > Hi,
    >> > I am trying to get a thorough understanding of a code where a addition
    >> > or
    >> > deletion of records can be done from a list of records. For addition
    >> > part
    >> > of
    >> > the form, data is being obtained from set of input boxes.
    >> > The following is the code being used:
    >> >
    >> > If Len(Request.Form("ID_0"))>0 Then
    >> > AuthorID=Request.Form("ID_0")
    >> > FName=Request.Form("fName_0")
    >> > LName=Request.Form("lName_0")
    >> >
    >> > ' SQL will break on names like O'Leary
    >> > ' if single quotes are not doubled.
    >> > LName=Replace(LName,"'","''")
    >> >
    >> > Phone=Request.Form("Phone_0")
    >> > Address=Request.Form("Address_0")
    >> > City=Request.Form("City_0")
    >> > State=Request.Form("State_0")
    >> >
    >> > ' Create the UPDATE SQL Statement
    >> > sql = " INSERT INTO Authors (au_id, au_fName, "
    >> > sql = sql & "au_lName, phone, address, city, state)"
    >> > sql = sql & " VALUES('" & AuthorID & "','" & FName
    >> > sql = sql & "','" & LName & "','" & Phone
    >> > sql = sql & "','" & Address & "','" & City
    >> > sql = sql & "','" & State & "')"
    >> >
    >> > ' Execute the INSERT SQL
    >> > cnnPubs.Execute sql
    >> > intCount=1
    >> > End if
    >> > I am not clear where the 0 suffix is coming from in the following:
    >> > AuthorID=Request.Form("ID_0")
    >> > FName=Request.Form("fName_0")
    >> >
    >> > Thanks for any help.
    >> >

    >>
    >>
    >>
    >>
     
    Mark Schupp, Mar 26, 2005
    #6
    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. Brian Birtle
    Replies:
    2
    Views:
    2,048
    John Saunders
    Oct 16, 2003
  2. Kittie

    Clear Request.Form

    Kittie, May 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    5,428
    Karl Seguin [MVP]
    May 31, 2006
  3. Vishal
    Replies:
    6
    Views:
    2,126
    Gabriel Genellina
    Jul 12, 2007
  4. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,036
    Mark Fitzpatrick
    Jan 31, 2008
  5. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    971
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page