|
 |
asp_web_howto thread: adding data from a self-submitting form to an array
Message #1 by "Eve Ukwu" <echioma@h...> on Sun, 9 Mar 2003 15:25:19
|
|
Hi,
I've got a self-submitting form where users can enter data and submit as
many times as they like. I need to increment the array each time the
user, submits the form but am having difficulty with it. Any help would
be greatly appreciated, and my code is something like this:
<%
dim intFriend, intFriendTotal, strAddFriend ,strSubmitFriend
dim strFName, strLName, arrFriend, arrFriendTotal,FriendNo,i
intFriend = 0
FriendNo = CInt(intFriend) + 1
strAddFriend = ""
strSubmitFriend = ""
strFName = ""
strLName = ""
%>
<%
if Request.ServerVariables("REQUEST_METHOD")= "POST" then
strFName = Trim(Request.Form("txtFName"))
strLName = Trim(Request.Form("txtLName"))
strAddFriend = Trim(Request.Form("addFriend"))
strSubmitFriend = Trim(Request.Form("submitFriend"))
if strAddFriend = "addFriend" then
Redim arrFriend(2,FriendNo)
arrFriend(0,FriendNo) = intFriend
arrFriend(1,FriendNo) = strFName
arrFriend(2,FriendNo) = strLName
Session("arrFriend") = arrFriend
if isArray(Session("arrFriend")) then
arrFriendTotal = session("arrFriend")
for i = 0 to UBound(arrFriendTotal,2)
if arrFriendTotal(0,i) = intFriend then
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
end if
next
else
Response.write "no data in array"
end if
end if
%>
Message #2 by "TomMallard" <mallard@s...> on Sun, 9 Mar 2003 10:28:51 -0800
|
|
-----Original Message-----
From: mallard [mailto:mallard@m...]
Sent: Sunday, March 09, 2003 8:25 AM
To: ASP Web HowTo
Subject: RE: [asp_web_howto] adding data from a self-submitting form to
an array
Redim Preserve
Without the preserve, it won't keep what was previously in the array.
tom mallard
seattle
-----Original Message-----
From: Eve Ukwu [mailto:echioma@h...]
Sent: Sunday, March 09, 2003 3:25 PM
To: ASP Web HowTo
Subject: [asp_web_howto] adding data from a self-submitting form to an
array
Hi,
I've got a self-submitting form where users can enter data and submit as
many times as they like. I need to increment the array each time the
user, submits the form but am having difficulty with it. Any help would
be greatly appreciated, and my code is something like this:
<%
dim intFriend, intFriendTotal, strAddFriend ,strSubmitFriend
dim strFName, strLName, arrFriend, arrFriendTotal,FriendNo,i
intFriend = 0
FriendNo = CInt(intFriend) + 1
strAddFriend = ""
strSubmitFriend = ""
strFName = ""
strLName = ""
%>
<%
if Request.ServerVariables("REQUEST_METHOD")= "POST" then
strFName = Trim(Request.Form("txtFName"))
strLName = Trim(Request.Form("txtLName"))
strAddFriend = Trim(Request.Form("addFriend"))
strSubmitFriend = Trim(Request.Form("submitFriend"))
if strAddFriend = "addFriend" then
Redim arrFriend(2,FriendNo)
arrFriend(0,FriendNo) = intFriend
arrFriend(1,FriendNo) = strFName
arrFriend(2,FriendNo) = strLName
Session("arrFriend") = arrFriend
if isArray(Session("arrFriend")) then
arrFriendTotal = session("arrFriend")
for i = 0 to UBound(arrFriendTotal,2)
if arrFriendTotal(0,i) = intFriend then
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
arrFriendTotal(0,i) = arrFriendTotal(0,i)+ 1
end if
next
else
Response.write "no data in array"
end if
end if
%>
|
|
 |