View Full Version : Iterating through form fields
10-26-2003, 07:49 PM
I need to go through the rows on a form and see if a checkbox is checked. If so I need to get the value of a field in the same row. So it would be like this;
for each fld in request.form
If fld.name="OnOrOff" and fld.Value="True" Then
I can't seem to find a reference to this. Is it possible?
You need to include one unique value as part of all related formfields.
I gave an example here:
10-26-2003, 09:28 PM
As usual you came through with exactly what I needed. Although I ended up doing it a little differently than your example. I wanted to be able to check several boxes, click done and have those checked deleted from my DB. What clued me in was your comment
Only checked boxes will be in the formscollection
I had misused the checkbox in my first attempt. I put my code here in case someone else has a similar problem. The form action calls this form so I look for records to delete, then requery the DB then paint the page.
Dim RS, SQL, dbCnxn, intCount
For intCount=1 to Request.Form("deleteMe").Count
SQL="DELETE FROM Users WHERE UserID=" & Request.Form("deleteMe")(intCount)
SQL="Select * FROM Users ORDER BY UserLName"
%><form id="delUsrs" Name="delUsrs" action="delUser.asp" method="Post">
<table id="usrTbl" width="100%">
<th align="left">Last Name</th>
<th align="left">Screen Name</th>
While NOT (RS.EOF)
<td align="center"><input type="CheckBox" name="deleteMe" value="<% =RS("UserID") %>"></td>
<td><% =RS("UserFName") %></td><td><% =RS("UserLName") %></td>
<td><% =RS("UserHandle") %></td>
<td><input type="submit" value="Done"></td>
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.