checkbox syntax

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 [ Mi, 14 November 2007 16:14 ] [ ID #1870465 ]

Re: checkbox syntax

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 [ Mi, 14 November 2007 17:06 ] [ ID #1870466 ]

Re: checkbox syntax

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.
reb01501 [ Mi, 14 November 2007 17:21 ] [ ID #1870467 ]

Re: checkbox syntax

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 [ Mi, 14 November 2007 17:51 ] [ ID #1870469 ]

Re: checkbox syntax

"Mike P" <mike.parr [at] gmail.com> wrote in message
news:%23MQ3J6tJIHA.3356 [at] TK2MSFTNGP02.phx.gbl...
> 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 [ Do, 15 November 2007 12:37 ] [ ID #1871543 ]
Webserver » microsoft.public.inetserver.asp.general » checkbox syntax

Vorheriges Thema: gevraagd: 2 ASP-scriptjes
Nächstes Thema: Local Testing Using SQL Server