Check Box Problem

T

Tony

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
 
T

Terry

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
 
R

Ray at

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
 
R

Ray at

p.s. To further confuse you, you can do this. ;]

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

Ray home

Ray at said:
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 said:
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
 

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

Similar Threads

Selective check box selector 3
CHECK BOX Problem 2
Check Box ! 1
Shaded check box? 38
Checking check box does not chage query result 3
Check box 5
Check Box Question 3
Show Field When Check Box Is Checked 3

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,366
Latest member
IanCulpepp

Latest Threads

Top