checkbox syntax

M

Mike P

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
 
D

Dooza

Mike said:
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

Try using Request.Form instead
 
B

Bob Barrows [MVP]

Mike said:
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
 
M

Mike P

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
 
A

Anthony Jones

Mike P said:
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 ?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top