I'm just right baffled with this and I'm at my wits end.
I have a form that queries a database and displays the results on a page in a table. The results are displayed in the following format:
As can be seen by the while loop, this will produce several lines with three values (FirstName, LastName, AccountNumber) each associated with an ID (AccountID).
The input fields allow the user to make changes in the contents and upon pressing "submit", the changes are to be sent to the database. There can be multiple lines so it would require as many updates to the database as there are lines.
I've tried two things, and I can't progress beyond processing the data into the update.
First method:
set the name of the input variables to AccountID (taken from the RecordSet). Using this and the following kludge of code:
I managed to get the following:
This corresponded to AccountID, FirstName, LastName, AccountNumber respectively.
I tried to use this in the SQL statement, but the three variables (FirstName, LastName, AccountNumber) are one string and I can't figure out how to parse them out of the single string (which is what Request.Form(key) winds up being due to the naming all the input tags the same).
Second method:
I named the various form elements to something different. I associated them with the AccountID though. Using a for loop to go through each individual element, I wound up with the following results:
Looking at that, I couldn't figure out what to do with it. The variable names themselves are skewy. Because they didn't seem to process in order, I couldn't put them into one SQL update call. At best, it would take six updates to the database, one for each value, which doesn't seem the smart way to do it.
So what am I missing here? This can't be that complicated. Please help!
I have a form that queries a database and displays the results on a page in a table. The results are displayed in the following format:
Code:
<% while NOT AccountsRS.EOF %>
<tr><td>First Name:</td>
<td><input type="text" value="<%=AccountsRS("FirstName")%>" name="<%=AccountsRS("AccountID")%>"></td>
<td>Last Name:</td>
<td><input type="text" value="<%=AccountsRS("LastName")%>" name="<%=AccountsRS("AccountID")%>"></td>
<td>Account #:</td>
<td><input type="text" value="<%=AccountsRS("AccountNumber")%>" name="<%=AccountsRS("AccountID")%>"></td></tr>
<% AccountsRS.MoveNext
wend %>
As can be seen by the while loop, this will produce several lines with three values (FirstName, LastName, AccountNumber) each associated with an ID (AccountID).
The input fields allow the user to make changes in the contents and upon pressing "submit", the changes are to be sent to the database. There can be multiple lines so it would require as many updates to the database as there are lines.
I've tried two things, and I can't progress beyond processing the data into the update.
First method:
set the name of the input variables to AccountID (taken from the RecordSet). Using this and the following kludge of code:
Code:
for each key in Request.Form
if NOT key = "submit" then
Response.Write ("<p>" & key & " = " & Request.Form(key) & "</br>")
end if
next
I managed to get the following:
Code:
1407 = Jim, James, 123456
1510 = John, George, 98765
This corresponded to AccountID, FirstName, LastName, AccountNumber respectively.
I tried to use this in the SQL statement, but the three variables (FirstName, LastName, AccountNumber) are one string and I can't figure out how to parse them out of the single string (which is what Request.Form(key) winds up being due to the naming all the input tags the same).
Second method:
I named the various form elements to something different. I associated them with the AccountID though. Using a for loop to go through each individual element, I wound up with the following results:
Code:
FirstName1407 = Jim
LastName1407 = James
FirstName1510 = John
AccountNumber1407 = 123456
LastName1510 = George
AccountNumber1510 = 98765
Looking at that, I couldn't figure out what to do with it. The variable names themselves are skewy. Because they didn't seem to process in order, I couldn't put them into one SQL update call. At best, it would take six updates to the database, one for each value, which doesn't seem the smart way to do it.
So what am I missing here? This can't be that complicated. Please help!