Forum Moderators: open
i.e.
<form>
<table>
<tr>
<td><input type = "text" name = "name1"></td>
<td><input type = "text" name = "email1"></td>
</tr>
<tr>
<td><input type = "text" name = "name2"></td>
<td><input type = "text" name = "email2"></td>
</tr>
<tr>
<td><input type = "text" name = "name3"></td>
<td><input type = "text" name = "email3"></td>
</tr>
<tr>
<td><input type = "text" name = "name4"></td>
<td><input type = "text" name = "email4"></td>
</tr>
</table>
</form>
now, i am wondering if there is a way to loop through the contents of the form collection, and perform an action.
<%
for i=0 to collection.count
if request.form("name" & i) <> "" then
name = request.form("name" & i)
email = request.form("email" & i)
end if
next
%>
i know collection.count is incorrect, but i'm just trying to convey the idea. my dilemma is that maybe only 2 rows are filled out... i only need to perform the action on the data that is entered, not on the blank fields. can i dynamically loop through the form names like that? i'm trying to condense 10 separate actions down into one loop.
i'm having a hard time explaining this, so if you are confused don't hesitate to ask questions. thanks to anyone who understands.
-Matt
For Each lsFrmField In Request.Form
Select Case lsFrmField
Case "tbsEmail", "cmbKontakt", "tbsCc", "tbsBcc", "tbsSubject", "tbnImportance", "tbsAnswerfile"
' do whatever you want with the header-fields
lsMsgBody = lsMsgBody
Case Else
' compose body
lsMsgBody = lsMsgBody & Request.Form
End Select
Next