Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping Through Objects on ASP Page

Status
Not open for further replies.

shellieb

Programmer
Aug 5, 2002
1
GB
I have an ASP page with lots of check boxes on it. I want to loop through each of them and check whether they have been checked. What I dont know is what the collection of objects in an asp page is called?

Thanks
 
You could do somthing like this:
Note- you will only get those check boxes that
are checked.

dim oColl, oItem
' Determine collection to use
if Request.QueryString <> &quot;&quot; then
set oColl = Request.QueryString
else
set oColl = Request.Form
end if
' Loop through collection
for each oItem in oColl
oItem = ucase(oItem)
if left(oItem) = &quot;chk&quot; then
''''''do your logic here.
end if
next
 
Another resolution that works for all checkbox's that I use is (assuming all checkboxes begin with &quot;chk&quot; in their name)

For Each itm In Request.Form
if left(itm,3) = &quot;chk&quot; then
if request.form(itm).count = 1 'it is true (0 is false)
...
...
end if
end if
next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top