if statement with checkbox.checked

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cary

    if statement with checkbox.checked

    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(myFor m) {
    var foo;
    foo = myForm.chkverif ied.checked;

    alert(foo);

    return false;
    }

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

    function funcCheck(myFor m) {
    var foo;
    foo = myForm.chkverif ied.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.chkveri fied.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
  • Lasse Reichstein Nielsen

    #2
    Re: if statement with checkbox.checke d

    cary.white@reli antgeneral.com (Cary) writes:
    [color=blue]
    > If (foo) {[/color]

    Javscript is case sensitive. You must write "if" in all lowercase.

    Good luck!
    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Vjekoslav Begovic

      #3
      Re: if statement with checkbox.checke d

      "Cary" <cary.white@rel iantgeneral.com > wrote[color=blue]
      > However if I do this:
      > function funcCheck(myFor m) {
      > var foo;
      > foo = myForm.chkverif ied.checked;
      >
      > If (foo) {
      > //do some code here
      > }
      > return false;
      > }[/color]
      Should be:

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


      Comment

      • Cary

        #4
        Re: if statement with checkbox.checke d

        "Vjekoslav Begovic" <vjbegovic@inet .hr> wrote in message[color=blue]
        > if (foo){....}
        > Javascript is case-sensitive.[/color]

        Doh! I knew it was something stupid. Many thanks!

        Comment

        Working...