468,727 Members | 1,638 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,727 developers. It's quick & easy.

Request.form usage not clear

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.

Jul 22 '05 #1
5 1958
=?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)

Jul 22 '05 #2
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)

Jul 22 '05 #3
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" <Ja**@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
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.


Jul 22 '05 #4
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" <Ja**@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
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.


Jul 22 '05 #5
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" <Ja**@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
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" <Ja**@discussions.microsoft.com> wrote in message
news:FF**********************************@microsof t.com...
> 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.
>


Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Christopher Brandsdal | last post: by
6 posts views Thread by Drew | last post: by
2 posts views Thread by Eidolon | last post: by
2 posts views Thread by Shahid Juma | last post: by
10 posts views Thread by Mr Newbie | last post: by
6 posts views Thread by magix | last post: by
10 posts views Thread by sheldonlg | last post: by
32 posts views Thread by =?Utf-8?B?U2l2?= | last post: by
1 post views Thread by CARIGAR | last post: by
9 posts views Thread by bryonone | last post: by
xarzu
1 post views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.