if statement with checkbox.checked

C

Cary

Hi all,

I seem to be losing my mind here. I can't get this to work and I know
it must be something stupid. I have an asp page with a html checkbox
on it. I have a button that calls a javascript with the onclick
method. I need to do or not do something based on the value of the
checkbox. To make this a simple as possible I have removed everything
I was needing to do, etc. I know the value is getting passed because
I can display it. This function works fine:

function funcCheck(myForm) {
var foo;
foo = myForm.chkverified.checked;

alert(foo);

return false;
}

It will show the alert with "true" or "false" accordingly. However if
I do this:

function funcCheck(myForm) {
var foo;
foo = myForm.chkverified.checked;

If (foo) {
//do some code here
}
return false;
}

Then I get a

Error: missing ; before statement
Source File: http://blah blah.js
Line: 6, Column: 10
Source Code:
If (foo) {

Am I losing it? Shouldn't I be able to evaluate true or false? I've
tried it without using foo as in

If (myForm.chkverified.checked) {

And I still get the same error. I apologize if this is a completely
ignorant, newbie question (it sure seems like one to me) but I just
can't believe this doesn't work.

Thanks for any help

Cary
 
V

Vjekoslav Begovic

Cary said:
However if I do this:
function funcCheck(myForm) {
var foo;
foo = myForm.chkverified.checked;

If (foo) {
//do some code here
}
return false;
}
Should be:

if (foo){....}
Javascript is case-sensitive.
 

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

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top