Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Iterating through form fields

    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;

    Code:
    for each fld in request.form
         If fld.name="OnOrOff" and fld.Value="True" Then
                thisOne=request.form("ThisRec") 
         End If
    Next
    I can't seem to find a reference to this. Is it possible?
    Scott Stewart
    Always happy to learn from pros.

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to include one unique value as part of all related formfields.

    I gave an example here:
    http://www.codingforums.com/showthre...threadid=27902

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks Raf,

    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.

    Code:
    <% 
        Dim RS, SQL, dbCnxn, intCount
    	Call OpenConnection()
    	For intCount=1 to Request.Form("deleteMe").Count
    	    SQL="DELETE FROM Users WHERE UserID=" & Request.Form("deleteMe")(intCount)
    	    dbcnxn.Execute SQL
    	Next
    	SQL="Select * FROM Users ORDER BY UserLName"
    	Set RS=dbcnxn.Execute(SQL)
    	%><form id="delUsrs" Name="delUsrs" action="delUser.asp" method="Post">
    	<table id="usrTbl" width="100%">
    	<tr>
    	    <th align="center">Del</th>
                        <th align="left">FirstName</th>
                        <th  align="left">Last Name</th>
                        <th align="left">Screen Name</th>
    	</tr><%
    	While NOT (RS.EOF)
    		  %>
    		  <tr>
    		       <td align="center"><input type="CheckBox" name="deleteMe" value="<% =RS("UserID") %>"></td>
                          <td><% =RS("UserFName") %></td><td><% =RS("UserLName") %></td>
                          <td><% =RS("UserHandle") %></td>
    		   </tr><% RS.MoveNext
    	Wend
    	%><tr>
                            <td><input type="submit" value="Done"></td>
                          </tr>
    	</table></form>
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •