470,648 Members | 1,381 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,648 developers. It's quick & easy.

Check Box Problem

On PageA I have:
<Input Type="CheckBox" Name="chkBox" Size="1" Value="True"
checked>

Which works fine!

On PageB I have;
<%If Request("chkBox")=True Then
Response.Write "True"
Else
Response.Write "False"
End If%>

This is where I am having trouble.

Can I see if the Check Box has been checked in VBScript or
do I have to use Java?, where I am very poor.

This is the fifth time I have submitted this. Either I am
having a difficult time understanding what I have been
instructed or it might be more difficult than people
think. I am not a very good programmer, I am a math
teacher and loved assembler. This object stuff confuses
me.

Thanx in Advance

Tony Zine
Jul 19 '05 #1
3 13596
Both of the following work:

1. In the following, you don't have to test against TRUE:

<%If Request("chkBox") Then
Response.Write "True"
Else
Response.Write "False"
End If%>
2. This is almost the same as what you had, but since the 'value' for
your checkbox (on your first form) is "True", you need to test against
'True' in quotes. And it is case-sensitive. If your 'value' for the
checkbox was 'itschecked', then 'If Request("chkBox")="itschecked"'
would also work.

<%If Request("chkBox")="True" Then
Response.Write "True"
Else
Response.Write "False"
End If%>
I don't have a good explanation at to why your version doesn't work
.... seems like the test should resolve to boolean TRUE, which should
work. Maybe someone else can respond to that.

Terry

On Mon, 15 Dec 2003 19:56:36 -0800, "Tony" <na*****@zianet.com> wrote:
On PageA I have:
<Input Type="CheckBox" Name="chkBox" Size="1" Value="True"
checked>

Which works fine!

On PageB I have;
<%If Request("chkBox")=True Then
Response.Write "True"
Else
Response.Write "False"
End If%>

This is where I am having trouble.

Can I see if the Check Box has been checked in VBScript or
do I have to use Java?, where I am very poor.

This is the fifth time I have submitted this. Either I am
having a difficult time understanding what I have been
instructed or it might be more difficult than people
think. I am not a very good programmer, I am a math
teacher and loved assembler. This object stuff confuses
me.

Thanx in Advance

Tony Zine


Jul 19 '05 #2
What part of the previous replies don't you understand? In what you have
below, you can know if the user checked the checkbox AFTER THE USER CLICKS
SUBMIT, by using:

<%
If Request.Form("chkBox") = "True" Then
Response.Write "True"
Else
Response.Write "False"
End If
%>

The value submitted in the form isn't an actual boolean value. It's merely
a string that says "true." You can give your checkbox a value "kajsdf" and
then do:

<% If request.form("chkBox") = "kajsdf" Then response.write "true" %>

Additionally, if you just want to know if the checkbox was checked, all you
really need to check for is if
Request.form("chkBox") <> ""

If the checkbox has a value, and the form is submitted with the checkbox
checked, the value of it will NOT be an empty string.
You may wonder what the point of having a checkbox value is then if it can
be anything arbitrary to find out if it was checked, but we can cover the
usefulness in a future post. :]

One last thing: As a math teacher, you should appreciate this, if you have
not yet heard about it.
http://www.foxnews.com/story/0,2933,105383,00.html

It's pretty amazing that a number that large...

Ray at home

"Tony" <na*****@zianet.com> wrote in message
news:14*****************************@phx.gbl...
On PageA I have:
<Input Type="CheckBox" Name="chkBox" Size="1" Value="True"
checked>

Which works fine!

On PageB I have;
<%If Request("chkBox")=True Then
Response.Write "True"
Else
Response.Write "False"
End If%>

This is where I am having trouble.

Can I see if the Check Box has been checked in VBScript or
do I have to use Java?, where I am very poor.

This is the fifth time I have submitted this. Either I am
having a difficult time understanding what I have been
instructed or it might be more difficult than people
think. I am not a very good programmer, I am a math
teacher and loved assembler. This object stuff confuses
me.

Thanx in Advance

Tony Zine

Jul 19 '05 #3
p.s. To further confuse you, you can do this. ;]

Response.Write CBool(Request.Form("chkBox"))

Ray home

"Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
What part of the previous replies don't you understand? In what you have
below, you can know if the user checked the checkbox AFTER THE USER CLICKS
SUBMIT, by using:

<%
If Request.Form("chkBox") = "True" Then
Response.Write "True"
Else
Response.Write "False"
End If
%>

The value submitted in the form isn't an actual boolean value. It's merely a string that says "true." You can give your checkbox a value "kajsdf" and then do:

<% If request.form("chkBox") = "kajsdf" Then response.write "true" %>

Additionally, if you just want to know if the checkbox was checked, all you really need to check for is if
Request.form("chkBox") <> ""

If the checkbox has a value, and the form is submitted with the checkbox
checked, the value of it will NOT be an empty string.
You may wonder what the point of having a checkbox value is then if it can
be anything arbitrary to find out if it was checked, but we can cover the
usefulness in a future post. :]

One last thing: As a math teacher, you should appreciate this, if you have not yet heard about it.
http://www.foxnews.com/story/0,2933,105383,00.html

It's pretty amazing that a number that large...

Ray at home

"Tony" <na*****@zianet.com> wrote in message
news:14*****************************@phx.gbl...
On PageA I have:
<Input Type="CheckBox" Name="chkBox" Size="1" Value="True"
checked>

Which works fine!

On PageB I have;
<%If Request("chkBox")=True Then
Response.Write "True"
Else
Response.Write "False"
End If%>

This is where I am having trouble.

Can I see if the Check Box has been checked in VBScript or
do I have to use Java?, where I am very poor.

This is the fifth time I have submitted this. Either I am
having a difficult time understanding what I have been
instructed or it might be more difficult than people
think. I am not a very good programmer, I am a math
teacher and loved assembler. This object stuff confuses
me.

Thanx in Advance

Tony Zine


Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by pw | last post: by
6 posts views Thread by Shannan Casteel via AccessMonster.com | last post: by
1 post views Thread by scprosportsman | last post: by
6 posts views Thread by tommaso.gastaldi | last post: by
12 posts views Thread by tshad | last post: by
2 posts views Thread by Ben | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.