Friday, September 24, 2010

Getting the values of checkbox in ASP form

Checkbox are shown to visitors to get the opinion on a fixed value. Sometime the visitors may have to submit more than one choice out of a group of options

In this article I am simply demonstrating how to get the values of all the checkboxes selected by visitors in classic ASP form

1. Create an selectoption.asp page
2. Put following line of code in it


In the above code the name of all the check boxes are same with different values so they will be treated as a group of checkbox.

3. Now create a ASP page with the name processing.asp and put the bellow mention code in it

Dim strmode, Arrmode,i
strmode =Request("test1 ")

We have used test1 as the common name so all the values of the checkbox for which the visitor has checked will be available as Request("test1 ") as comma separated values. So in the above code the variable mode value will be consisting of all checked values separated by comma. 

4. Now let split the string to get the array of checked values.
Arrmode _a=split(strmode,",")

5. Now we will loop through the array by using for for loop and UBound function to print out the checked values of the checkboxes. 
For i=LBound(Arrmode) to UBound(Arrmode)
        Response.Write Arrmode_a(i) + " "


  1. That is an excellent and concise example. The only problem I see is that mode_a(i) should be Armode_a(i).

  2. why are you giving different variable names in the example???

    1. just to add more readability, if you want you can use the same variable name . Thanks

  3. This comment has been removed by the author.