How do I pass values of checkboxes

Results 1 to 3 of 3

Thread: How do I pass values of checkboxes

  1. #1
    Join Date
    Dec 1969

    Default How do I pass values of checkboxes

    Hi all,<BR><BR>Let me give you the setup.<BR><BR>I have page that is made up of check boxes. The number of and names of the check boxes on the page depends on the results of a stored procedure in SQL Server. After the user checks the appropriate boxes what is the best way to get the values into variables on the next page. I wont be sure how many variable to create and what to name them because it will depend on the results of the stored procedure from the previous page.<BR><BR>Any suggestions are appreciated,<BR>Justin

  2. #2
    Joel N. Guest

    Default RE: How do I pass values of checkboxes

    What&#039;s your naming convention for the checkboxes? Do they share a common prefix? For instance, if all the checkboxes names will start with "chk" you could do someting like this on the processing page:<BR><BR>&#060;%<BR>Dim arrValues()<BR>Dim ctr<BR>ctr = 1<BR>For Each itm In Request.Form<BR> If InStr(1, itm.Name, "chk", 1) &#062; 0 Then<BR> ReDim Preserve arrValues(ctr) <BR> arrValues(ctr) = Request.Form(itm.Name).Value<BR> ctr = ctr + 1<BR> End If<BR>Next<BR>%&#062;<BR>Now arrValues() has an element in it for every checkbox that was submitted if it matches the checkbox element&#039;s name common prefix. Just remember that arrays are zero based so if you sent 5 checkboxes through then arrValues(0) to arrValues(4) will hold the 5 values. You can use UBound to determine the size of the array so you can iterate through it without knowing ahead of times how many values you&#039;ll be getting.<BR><BR>If the checkboxes don&#039;t share a common naming convention then it&#039;s going to be a lot harder to pull this one off. Not impossible, but conventions are useful in this case.

  3. #3
    Join Date
    Dec 1969

    Default RE: How do I pass values of checkboxes

    Why dont you look at the sql within the stored procedure and use the same names that the procedure is using..

Posting Permissions

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