Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Looping through form submitted data

Author  Topic 

nicki_assumption
Yak Posting Veteran

69 Posts

Posted - 2005-09-09 : 13:54:48
Hi- I'm trying to take a form which is populated with data from a database and then update the data in the db. I have the form displaying correct data - there is a loop of rows and for each row, i have a drop down box for selecting one thing. I need to have the form submit back to me in an array I guess but I don't know how to do that in ASP. I would like to loop back through my data with the new values and update each row in the loop. Here is my form (I guess my questions is how to create the array in the form submission so I can create a query from the results): both info and group_info are the results of a query...THanks


<form action="test.asp?sid=<%=sid%>" method="post" name="advisee_update">

<%
Do While Not info.EOF %>
<center><strong><%=info("First_Name")%> <%=info("Middle_Name")%> <%=info("Last_Name")%> - <%=info("Class_Year")%></strong>
<input type="hidden" name="student_id" value="<%=info("Student_ID")%>">"
<select name="webgroup">
<!-- create an array to check what they have been assigned in web table and make selected=selected if it's there -->
<option selected="" value="">Unassigned</option>
<% Set Group_info = Connect.Execute(Groups)
Do While Not Group_info.EOF %>
<option value="<%=Group_info("Web_Group_Reg_ID")%>"> <%=Group_info("Description")%> </option>
<%
Group_info.MoveNext
Loop
%>
</select>
</center><br>
<%
info.MoveNext
Loop
'End If
%>
<center><input name="page" type="submit" value="Submit" />
</center>
</form>

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-10 : 07:20:30
what kind of array??

you can do something like this:
dim yourarray(0), i
i=0
while some condition
yourarray(i) = request("objectname") & ','
i = i+1
redim preserve yourarray(i)
wend


Go with the flow & have fun! Else fight the flow
Go to Top of Page

nicki_assumption
Yak Posting Veteran

69 Posts

Posted - 2005-09-12 : 09:34:21
Well, I guess it has to be a multi dimensional. If i were in php, i would have each form element a part of an array with a counter associated with it and then when the form is submitted, i would have to go through each key to access all the elements from that array.
I'm not sure I understant the "object" part of your code example.

If I had
While I'm looping through names
FirstName: <input name=first_names[$i] value="<%=info("Last_Name")%>">
<br>
Last Name: <input name=last_names[$i] value=="<%=info("Last_Name")%>">

$i++;
end looping

Then somehow parse it after it is submitted?
Is there a good tutorial for doing forms in ASP- that might help me.
Thanks a lot, Nicki
Go to Top of Page
   

- Advertisement -