checkbox syntax

Discussion in 'ASP General' started by Mike P, Nov 14, 2007.

  1. Mike P

    Mike P Guest

    I am posting a form to a page and then trying to pick up the value of a
    checkbox. But I can't get the syntax right. Can anybody help?

    dim blnInboundLead4

    blnInboundLead4 = true

    if (Request("inboundlead2") = "off") then
    blnInboundLead4 = false
    end if



    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Nov 14, 2007
    #1
    1. Advertising

  2. Mike P

    Dooza Guest

    Mike P wrote:
    > I am posting a form to a page and then trying to pick up the value of a
    > checkbox. But I can't get the syntax right. Can anybody help?
    >
    > dim blnInboundLead4
    >
    > blnInboundLead4 = true
    >
    > if (Request("inboundlead2") = "off") then
    > blnInboundLead4 = false
    > end if
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***


    Try using Request.Form instead
    Dooza, Nov 14, 2007
    #2
    1. Advertising

  3. Mike P wrote:
    > I am posting a form to a page and then trying to pick up the value of
    > a checkbox. But I can't get the syntax right. Can anybody help?
    >
    > dim blnInboundLead4
    >
    > blnInboundLead4 = true
    >
    > if (Request("inboundlead2") = "off") then
    > blnInboundLead4 = false
    > end if
    >
    >

    If the checkbox is not selected, it does not appear in the Form
    collection. What you have to do is check for the existence of the key
    and set the boolean variable accordingly:

    dim blnInboundLead4
    if len(Request.Form("inboundlead2")) > 0 then
    blnInboundLead4 = true
    else
    blnInboundLead4 = false
    end if
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Nov 14, 2007
    #3
  4. Mike P

    Mike P Guest

    It worked once I had changed true and false to "true and "false" :

    dim blnInboundLead4
    if len(Request.Form("inboundlead2")) > 0 then
    blnInboundLead4 = "true"
    else
    blnInboundLead4 = "false"
    end if




    *** Sent via Developersdex http://www.developersdex.com ***
    Mike P, Nov 14, 2007
    #4
  5. "Mike P" <> wrote in message
    news:%...
    > It worked once I had changed true and false to "true and "false" :
    >
    > dim blnInboundLead4
    > if len(Request.Form("inboundlead2")) > 0 then
    > blnInboundLead4 = "true"
    > else
    > blnInboundLead4 = "false"
    > end if
    >


    In which case perhaps your variable name should be strInbound ?

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Nov 15, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    0
    Views:
    510
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,385
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    809
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    542
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    509
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page