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
    New Coder
    Join Date
    Nov 2002
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Retrieve the value of multiple checkbox

    Hi! Here am I again with a (maybe stupid...) problem:

    I have on a page 8 checkboxs. I'm doing something like this:
    <form action = "2.asp">
    <%for i =1 to 8%>
    <TR>
    <TD><INPUT type="checkbox" id=checkbox1 name="pendente<%=i%>"></TD>
    </TR>
    <%next%>
    </form>

    How can I, on the "2.asp" page, when I'm doing my SQL Insert string, retrieve the value of those checkbox's? I need to know If the first is "on" or not, the second, and so on...

    I can't do this!!! I've been trying for 2 days!
    Please help...

    Thank's
    Paula

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    With checkboxes, the value that you get by default will be "on" if the box is checked or it will be null if the box isn't checked.

    <%
    for i =1 to 8
    response.write "The value of checkbox "&i&" is: "&request.querystring("pendente"&i)&"<br>"
    next
    %>
    The output will be the following if you check boxes 1, 5, and 8:

    The value of checkbox 1 is: on
    The value of checkbox 2 is:
    The value of checkbox 3 is:
    The value of checkbox 4 is:
    The value of checkbox 5 is: on
    The value of checkbox 6 is:
    The value of checkbox 7 is:
    The value of checkbox 8 is: on

    edit: You can use if-statements to change the null values to "off" since most people like strings better.
    Last edited by arnyinc; 02-17-2003 at 06:16 PM.

  • #3
    New Coder
    Join Date
    Nov 2002
    Posts
    62
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi!

    Just to thank's the help. It was just what I nedeed!...

    Paula


  •  

    Posting Permissions

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