Results 1 to 3 of 3

Thread: ASP and Script variables

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    50

    Question

    Hi all,

    I don't know whether I am a the right place or not, anyway, I am here now!
    My question is how to assign the value of Script variable to ASP variable, well this question is best understood by an example:

    * in 'Process.asp' I have the following:

    .
    .
    Application("UserName") = ""
    .
    .
    <script language=JavaScript>
    .
    .
    var tmpUser
    tmpUser = Application("UserName"); <<--- the problem here
    .
    .
    </script>

    The problem is that I can't assign the value of a Script variable to ASP variable (and vice versa by the way!).

    Can anyone help ??

    Thanks in advance,

    Poor Wesam !!

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    What error(s) are you getting?

    What exactly are you trying to do?
    It looks like you are truing to assign a server-side variable to client-side script


    Are you trying to write client side javascript?
    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    </HEAD>
    <BODY>
    <%
    Application("UserName") = "Mark"
    
    
    Response.Write "<script language=JavaScript>"
    Response.Write "var tmpUser;"
    Response.Write "tmpUser ='" & Application("UserName") & "';"
    Response.Write "</script> "
    
    %>
    
    </BODY>
    </HTML>

    or server side?

    Code:
    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    <%
    Application("UserName") = "Mark"
    
    %>
    <script language=JavaScript runat=server> 
      function XX(){
    var tmpUser;
    tmpUser = Application("UserName"); 
    
    return tmpUser;
     }
     
    </script> 
    <%
    Response.Write XX()
    %>
    
    </BODY>
    </HTML>
    Or none of these?
    Mark
    -------------------

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    50

    Thumbs up

    Ooh .. that's it, thank you for your help, I reviewed the code in your second example and I found that the problem was in the clause "<script language=JavaScript>" .. I did not specify "RunAt=Server" and that's why my code never worked.

    Thanks a lot,

    Happy Wesam !

Posting Permissions

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



Click Here to Expand Forum to Full Width