codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  loop through form checkboxes  serafina at 11:36 on Thursday, August 19, 2004
 

Hi
I want to loop through some checkboxes & extract their name & value. actually i want an if statement that says if they are empty write nothing & if they arent then extract name & value of checkbox. i know how to do the if & extract the values etc but not the loop. at the moment i have really long code that looks at each checkbox tests if its empty & if it isnt then extracts the values I need.

can anyone help? this is what my code is starting to look like

Dim strSC, strCDRom, strGLS
strSC = Trim(Request.Form("shortform catalogue"))
strCDROM = Trim(Request.Form("catalogue on CD Rom"))
strGLS = Trim(Request.Form("Guard Locking systems"))
If strSC = "" Then
strMain = strMain
Else
strMain = strMain & "Shortform catalogue: " & strSC &vbcrlf
End If
If strCDROM = "" Then
strMain = strMain
Else
strMain = strMain & "catalogue on CD Rom " & strCDROM &vbcrlf
End If

& there are 19 of these checkboxes
thanks

  Re: loop through form checkboxes  Troy Wolf at 19:17 on Monday, August 23, 2004
 

One method is to name all your checkboxes with a common prefix so you can programmatically identify them later. For example:

<input type=checkbox name="CB_Catalog" value=1>
<input type=checkbox name="CB_GuardLock" value=1>


Then in your ASP, do something like this:

for each field in Request.Fom
if Left(field,3) = "CB_" and Request.Form(field) <> "" then
strMain = strMain & field & ": " & Request.Form(field) & vbcrlf
end if
next



Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Page print
•  Re: Export database`s data into a CSV file in jspscript.....
•  Passing Remote Computer Name to Access Query
•  dynamically created tables containing layers
•  PDF
•  Re: How do I make the child close automatically after 3 seconds ?
•  Re: grouping records
•  Wrap Counter??
•  Login and Redirect -- Help Please


Recent Articles
Simple Thumbnail Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)
Function to Return Alpha Characters Only
The OSI Reference Model - A Clear and Concise Illustration !


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004