Syntax error

Discussion in 'JavaScript' started by richiej, Oct 5, 2007.

  1. #1
    Hi,

    I am testing out an idea for an application I am writing. I am trying to get a] DOM object to be a 'flag' to say that something has happened (textbox had its texted changed for instance) and then when a user clicks on a button an alert will appear if something has been changed. I am only proving an idea at this stage, in my full application the mechanism will a whole lot wider.

    However, I get a syntax error on my page and by commenting out lines I have determined that it is my first line that is causing the problem. Here is my code:
    <script>

    var oChange = null;
    /*
    function Call()
    {
    <%=sReturn%>
    }
    */
    function TestInterface()
    {
    if (oChange <> null)
    {
    window.alert("This is working");
    }
    }

    function TestChanges()
    {
    oChange = 'TRUE';
    }

    </script>

    The line with the colour change is the problem, I always thought u could declare DOM objects outside a function. Is this not the case?

    thanks in advance
     
    richiej, Oct 5, 2007 IP
  2. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try just

    var oChange;

    I don't know if you can assign a value when declaring a "global" like that.
     
    james_r, Oct 5, 2007 IP
  3. richiej

    richiej Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for the advice but no joy.... this is really annoying. I know this is possible!!:(
     
    richiej, Oct 9, 2007 IP