ASP within javascript

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

    ASP within javascript

    How can I pull this ASP var into javascript?
    What is wrong with this statement?

    <%
    todaysdate = (now)
    response.write (todaysdate)
    %>
    <script language="JavaS cript"><!--
    var date = new Date();
    var aspdate = <%=todaysdate %>
    document.write( aspdate);
    //--></script>



  • Evertjan.

    #2
    Re: ASP within javascript

    Targa wrote on 14 jun 2004 in comp.lang.javas cript:[color=blue]
    > How can I pull this ASP var into javascript?[/color]

    You mix up your terminology!

    Javascript does not mean clientside, as ASP can also use j(ava)script.

    ASP does not mean VBscript per se, see above,
    [and VBscript can also be used clientside in IE]
    [color=blue]
    > What is wrong with this statement?
    >
    > <%
    > todaysdate = (now)
    > response.write (todaysdate)[/color]

    ASP vbs:

    todaysdate = now
    response.write todaysdate

    ASP jscript:

    todaysdate = new Date();
    Response.write( todaysdate);

    [color=blue]
    > %>
    > <script language="JavaS cript"><!--[/color]

    <script type="text/JavaScript">
    [color=blue]
    > var date = new Date();[/color]

    not used
    [color=blue]
    > var aspdate = <%=todaysdate %>
    > document.write( aspdate);[/color]

    Is just a string, no javascript date, you write
    [color=blue]
    > //--></script>[/color]

    </script>
    [color=blue]
    >
    >[/color]



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Evertjan.

      #3
      Re: ASP within javascript

      Evertjan. wrote on 14 jun 2004 in comp.lang.javas cript:[color=blue][color=green]
      >> var aspdate = <%=todaysdate %>[/color][/color]

      todaysdate has spaces, so:

      var aspdate = "<%=todaysd ate %>"

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Vincent van Beveren

        #4
        Re: ASP within javascript

        Not much, maybe you should add ; at the end of

        var aspdate = <%=todaysdate %>

        though that shouldn't be the problem. Have you looked at the document
        source to see if the value is really written to the document?
        Besides that it looks fine to me.

        Targa wrote:[color=blue]
        > How can I pull this ASP var into javascript?
        > What is wrong with this statement?
        >
        > <%
        > todaysdate = (now)
        > response.write (todaysdate)
        > %>
        > <script language="JavaS cript"><!--
        > var date = new Date();
        > var aspdate = <%=todaysdate %>
        > document.write( aspdate);
        > //--></script>
        >
        >
        >[/color]

        Comment

        • Evertjan.

          #5
          Re: ASP within javascript

          Vincent van Beveren wrote on 14 jun 2004 in comp.lang.javas cript:
          [color=blue]
          > Not much, maybe you should add ; at the end of
          >
          > var aspdate = <%=todaysdate %>
          >[/color]

          This does not work if todaysdate has whitespace between words.


          var aspdate = "<%=todaysd ate %>"


          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          Working...