Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Undefined variable error, even though variable is defined

    Hello

    I have a php page in which I declared a js variable... right at the top of the page...

    <script type="text/javascript">
    var tester = 0;
    </script>


    Later in the page I test this variable...

    <script type="text/javascript">

    if (tester==1){

    do some stuff!!
    }

    </script>

    But I keep getting an error variable _tester undefined


    Am I missing something obvious... I am new to js... but this seems really straightforward

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Could you post the complete code taken from browser's view-source option?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    I keep getting an error variable _tester undefined
    ???? You define a variable named "tester" but I don't see you defining a variable name "_tester".
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •