• Getting information from CheckBoxes

    Home » Forums » Developers, developers, developers » Web design and development » Getting information from CheckBoxes

    Author
    Topic
    #392767

    I am trying to use CDONTS to take information from a form (http://www.scorecentralnebraska.org/Forms/SBA641OnlineForm.asp) and send it in an e-mail back to myself. My problem is that I cannot figure out how to pull information from the checkboxes and get them into the body of my message. If anybody has any advise that would be great. Many thanks in advance!

    The following is the code from the form:
    —————-

    9. Race (mark one or more)

    Native American or Alaskan Native

    Asian

    Black or African American

    Native Hawaiian or other Pacific Islander

    White

    —————-

    The next code is what I’m using to send the actuall e-mail with. This is located on the same page above the form.
    —————-

    <%
    if (cStr(Request("Submit")) “”) Then

    Dim objCDO
    Dim MessageBody
    Dim RaceA1

    Set objCDO = Server.CreateObject(“CDONTS.NewMail”)
    objCDO.From = Request(“Email”)
    objCDO.To = “freemans@intellicominc.com”
    objCDO.CC = “”
    objCDO.Subject = “Webform Request for Counseling”

    MessageBody = “The following was submitted from the website on ” & Now() & CHR(13)
    MessageBody = MessageBody & “———————————————” & CHR(13)
    MessageBody = MessageBody & “Name: ” & Request(“Name”) & CHR(13)
    MessageBody = MessageBody & “Home Phone:” & CHR(13)
    MessageBody = MessageBody & “Business Phone:” & CHR(13)
    MessageBody = MessageBody & “Fax:” & CHR(13)
    MessageBody = MessageBody & “E-Mail” & CHR(13)

    **** Here is where the code would go to include the information from the Checkboxes ****

    objCDO.Body = MessageBody
    objCDO.Send()
    Set objCDO = Nothing
    Response.Redirect(“http://www.scorecentralnebraska.org/index.html&#8221;)

    End If
    %>

    Any help would be greatly appreciated!

    Thanks,
    Shane

    Viewing 0 reply threads
    Author
    Replies
    • #707298

      The thing to remember about checkboxes is that if they’re not checked, they won’t show up in the Request.Form collection at all.

      So if its value is “on”, it’s checked – otherwise it’s not.

      You can use:
      If Request.Form(“RaceA”) = “on” Then
      ‘It’s true
      Else
      ‘It’s false
      End If

      • #707597

        I tried adding the following code, all on one line, but when I check RaceA in the form it always comes back with “false” in the message body. Any idea suggestions? I’ve attached the entire asp file if that helps any. Thanks for your help!

        Shane

        ————
        if Request.Form(“RaceA”)=”On” Then MessageBody = MessageBody & “True” & CHR(13) Else MessageBody = MessageBody & “False” & CHR(13)
        ————

        • #707603

          DOH!

          Sorry for the oversight on my part. Add the name=”” attribute to the Checkbox items on your HTML page (like )

          Hope this helps!

          • #707613

            I think it’s already there…
            ——-

            Native American or Alaskan Native
            ——-
            Does it matter what order they’re in or do id and name have to be different?

            • #707624

              My bad – I got in such a hurry that i forgot to read through the code you sent!

              I’m a little out of touch with Classic ASP at the moment – I’ve been using ASP.NET for quite a while now and I’ve honestly forgotten a lot of the details (like handling checkboxes).

              You may want to check out one of my favorite ASP resources: W3 Schools. Specifically, they have a page that talks about handling checkbox input: http://www.w3schools.com/asp/asp_ref_request.asp%5B/url%5D and the demo:
              http://www.w3schools.com/asp/showasp.asp?f…demo_checkboxes%5B/url%5D

              Sorry for the confusion shrug

            • #707625

              My bad – I got in such a hurry that i forgot to read through the code you sent!

              I’m a little out of touch with Classic ASP at the moment – I’ve been using ASP.NET for quite a while now and I’ve honestly forgotten a lot of the details (like handling checkboxes).

              You may want to check out one of my favorite ASP resources: W3 Schools. Specifically, they have a page that talks about handling checkbox input: http://www.w3schools.com/asp/asp_ref_request.asp%5B/url%5D and the demo:
              http://www.w3schools.com/asp/showasp.asp?f…demo_checkboxes%5B/url%5D

              Sorry for the confusion shrug

            • #708007

              You’ve changed the default value from On to Native American. You can see what effect this has with this test page (which you should name chkbx.asp so it calls itself):

              ASP Checkbox processing test

              A Wee Test of ASP Handling of HTML Checkboxes

              <%
              If Request.Form("cbWhatever") “” Then
              Response.Write ”

              The checkbox was checked! Its value is: ” & Request.Form(“cbWhatever”) & _
              (make a note of it!)” & vbCrLf
              Else
              Response.Write “The checkbox was not passed to me.” & vbCrLf
              End If
              %>


              Check me and
              submit! Or don’t check me. What do I care?

            • #709156

              Thanks to both of you for the information. After realizing some early mistakes, mainly changing the default value, I figured out what I had done wrong and managed to get everything working. Thanks again!

            • #709157

              Thanks to both of you for the information. After realizing some early mistakes, mainly changing the default value, I figured out what I had done wrong and managed to get everything working. Thanks again!

            • #708008

              You’ve changed the default value from On to Native American. You can see what effect this has with this test page (which you should name chkbx.asp so it calls itself):

              ASP Checkbox processing test

              A Wee Test of ASP Handling of HTML Checkboxes

              <%
              If Request.Form("cbWhatever") “” Then
              Response.Write ”

              The checkbox was checked! Its value is: ” & Request.Form(“cbWhatever”) & _
              (make a note of it!)” & vbCrLf
              Else
              Response.Write “The checkbox was not passed to me.” & vbCrLf
              End If
              %>


              Check me and
              submit! Or don’t check me. What do I care?

          • #707614

            I think it’s already there…
            ——-

            Native American or Alaskan Native
            ——-
            Does it matter what order they’re in or do id and name have to be different?

        • #707604

          DOH!

          Sorry for the oversight on my part. Add the name=”” attribute to the Checkbox items on your HTML page (like )

          Hope this helps!

      • #707598

        I tried adding the following code, all on one line, but when I check RaceA in the form it always comes back with “false” in the message body. Any idea suggestions? I’ve attached the entire asp file if that helps any. Thanks for your help!

        Shane

        ————
        if Request.Form(“RaceA”)=”On” Then MessageBody = MessageBody & “True” & CHR(13) Else MessageBody = MessageBody & “False” & CHR(13)
        ————

    Viewing 0 reply threads
    Reply To: Getting information from CheckBoxes

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: