error with variable declaration

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

    error with variable declaration

    Hi,

    My problem is:
    when i declare variable 'recuur' in Jscript like it is below, no problem.
    But if i declare 'recuur' like: var recuur=<%=recuu r%>
    then i get two errors:
    "totday is not defined" and "syntax error: var recuur=10"

    Any idea what's wrong?
    Thanks
    Kevin



    <%
    totday=request. cookies("totday ") => =14
    .....
    sql="select range from hr order by range;"
    set rs=Server.Creat eObject("ADODB. Recordset")
    rs.open sql, OBJDC, 3, 3
    dim allhr
    Set rs = objdc.execute(s ql)
    if not rs.eof then
    allhr = rs.GetRows()
    recuur = UBound(allhr, 2) + 1 => =10
    end if
    ....
    %>
    .....
    <script type="text/javascript">
    totday=<%=totda y%>
    recuur=<%=recuu r%>
    ....



  • Randy Webb

    #2
    Re: error with variable declaration

    Kevin said the following on 12/5/2005 3:37 PM:[color=blue]
    > Hi,
    >
    > My problem is:
    > when i declare variable 'recuur' in Jscript like it is below, no problem.
    > But if i declare 'recuur' like: var recuur=<%=recuu r%>
    > then i get two errors:
    > "totday is not defined" and "syntax error: var recuur=10"
    >
    > Any idea what's wrong?[/color]

    Show the actual code that gets sent to the browser, not the ASP Code
    that generates it.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • Kevin

      #3
      Re: error with variable declaration

      I found it.
      I was wrong: '<%=totday%>' had no value because the cookie had the wrong
      name.
      But what i still don't understand, is why the next line (var
      recuur=<%=recuu r%>) is considered as an syntax error and not without 'var'.
      If i insert ALERT between the two lines like this:
      totday=<%=totda y%>
      alert("ok")
      var recuur=<%=recuu r%>

      i get no error. Strange isn't it?


      "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
      news:x6mdnZuChe C9OgneRVn-gA@comcast.com. ..[color=blue]
      > Kevin said the following on 12/5/2005 3:37 PM:[color=green]
      > > Hi,
      > >
      > > My problem is:
      > > when i declare variable 'recuur' in Jscript like it is below, no[/color][/color]
      problem.[color=blue][color=green]
      > > But if i declare 'recuur' like: var recuur=<%=recuu r%>
      > > then i get two errors:
      > > "totday is not defined" and "syntax error: var recuur=10"
      > >
      > > Any idea what's wrong?[/color]
      >
      > Show the actual code that gets sent to the browser, not the ASP Code
      > that generates it.
      >
      > --
      > Randy
      > comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
      > Javascript Best Practices -[/color]



      Comment

      • Patrice

        #4
        Re: error with variable declaration

        As Randy said, jsut check the JS code created by your ASP pages... Also it
        looks like you forgot ; at the end of each line...
        --

        "Kevin" <kslite@smart.c a> a écrit dans le message de
        news:eDeJJ2j%23 FHA.4088@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > I found it.
        > I was wrong: '<%=totday%>' had no value because the cookie had the wrong
        > name.
        > But what i still don't understand, is why the next line (var
        > recuur=<%=recuu r%>) is considered as an syntax error and not without[/color]
        'var'.[color=blue]
        > If i insert ALERT between the two lines like this:
        > totday=<%=totda y%>
        > alert("ok")
        > var recuur=<%=recuu r%>
        >
        > i get no error. Strange isn't it?
        >
        >
        > "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
        > news:x6mdnZuChe C9OgneRVn-gA@comcast.com. ..[color=green]
        > > Kevin said the following on 12/5/2005 3:37 PM:[color=darkred]
        > > > Hi,
        > > >
        > > > My problem is:
        > > > when i declare variable 'recuur' in Jscript like it is below, no[/color][/color]
        > problem.[color=green][color=darkred]
        > > > But if i declare 'recuur' like: var recuur=<%=recuu r%>
        > > > then i get two errors:
        > > > "totday is not defined" and "syntax error: var recuur=10"
        > > >
        > > > Any idea what's wrong?[/color]
        > >
        > > Show the actual code that gets sent to the browser, not the ASP Code
        > > that generates it.
        > >
        > > --
        > > Randy
        > > comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
        > > Javascript Best Practices -[/color]
        > http://www.JavascriptToolbox.com/bestpractices/
        >
        >[/color]


        Comment

        • Randy Webb

          #5
          Re: error with variable declaration

          Patrice said the following on 12/6/2005 5:16 AM:[color=blue]
          > As Randy said, jsut check the JS code created by your ASP pages... Also it
          > looks like you forgot ; at the end of each line...[/color]

          The ; at the end of the line is optional and has no bearing on syntax
          errors.

          --
          Randy
          comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
          Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

          Comment

          • Randy Webb

            #6
            Re: error with variable declaration

            Kevin said the following on 12/6/2005 3:16 AM:[color=blue]
            > I found it.
            > I was wrong: '<%=totday%>' had no value because the cookie had the wrong
            > name.
            > But what i still don't understand, is why the next line (var
            > recuur=<%=recuu r%>) is considered as an syntax error and not without 'var'.
            > If i insert ALERT between the two lines like this:
            > totday=<%=totda y%>
            > alert("ok")
            > var recuur=<%=recuu r%>
            >
            > i get no error. Strange isn't it?[/color]

            It depends on what the server is sending to the browser. You have to
            check the code generated by the server (not the server side code) when
            trying to debug client-side script issues.

            --
            Randy
            comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
            Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

            Comment

            • Bob Barrows [MVP]

              #7
              Re: error with variable declaration

              Kevin wrote:[color=blue]
              > I found it.
              > I was wrong: '<%=totday%>' had no value because the cookie had the
              > wrong name.
              > But what i still don't understand, is why the next line (var
              > recuur=<%=recuu r%>) is considered as an syntax error and not without
              > 'var'. If i insert ALERT between the two lines like this:
              > totday=<%=totda y%>
              > alert("ok")
              > var recuur=<%=recuu r%>
              >
              > i get no error. Strange isn't it?
              >
              >[/color]

              Randy Webb wrote:[color=blue]
              > Kevin said the following on 12/6/2005 3:16 AM:[color=green]
              >> I found it.
              >> I was wrong: '<%=totday%>' had no value because the cookie had the
              >> wrong name.
              >> But what i still don't understand, is why the next line (var
              >> recuur=<%=recuu r%>) is considered as an syntax error and not without
              >> 'var'. If i insert ALERT between the two lines like this:
              >> totday=<%=totda y%>
              >> alert("ok")
              >> var recuur=<%=recuu r%>
              >>
              >> i get no error. Strange isn't it?[/color]
              >
              > It depends on what the server is sending to the browser. You have to
              > check the code generated by the server (not the server side code) when
              > trying to debug client-side script issues.
              >[/color]


              What Randy means is that you need to load the page into your browser and
              click View Source so you can see the final resulting javascript code.

              Bob Barrows
              --
              Microsoft MVP -- ASP/ASP.NET
              Please reply to the newsgroup. The email account listed in my From
              header is my spam trap, so I don't check it very often. You will get a
              quicker response by posting to the newsgroup.


              Comment

              Working...