Mixing Session Level Vars With Javascript

Results 1 to 4 of 4

Thread: Mixing Session Level Vars With Javascript

  1. #1
    Vipul Desai Guest

    Default Mixing Session Level Vars With Javascript

    Mixing VB SCRIPT AND Javascript<BR>Vipul Desai - 18 Oct - 09:29:52 AM<BR>--------------------------------------------------------------------------------<BR>I am a new user of Javascript within ASP applications. Essentially, I want to use Javascript as the sole language for developing my Browser based applications. I want to know that within a Javascript subroutine, can I invoke VBScript Server type variables and Application level variables. For instance, what I want to do can be described as follows. <BR><BR>&#060;% Dim nameofemp %&#062;<BR>function somefunction(jscriptname) <BR>{<BR>&#039I want to put the string variable jscriptname into <BR>&#039the VBScript variable called nameofemp. Can I do this?<BR><BR>}<BR><BR>&#060;Form&#062;<BR>&#060;In put Type = "Submit" Name = "txtText" onClick = "(somefunction("JIM JONES"))"&#062; <BR><BR>&#060;/Form&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Mixing Session Level Vars With Javascript

    It is important to understand the client/server nature of ASP pages. Please read:<BR>http://www.4guysfromrolla.com/webtech/082399-1.shtml<BR>for some background.<BR><BR>Now, to answer your question. Since ASP processes completely before the client receives the HTML, you can output the value of any ASP variable anywhere in your HTML by simply using:<BR>&#060;%=variableName%&#062;<BR><BR>So, you might want to do:<BR>&#060;Input Type = "Submit" Name = "txtText" onClick = "(somefunction("&#060;%=NameOfEmp%&#062;"))"&# 062; <BR><BR>Note that I just placed the &#060;%=VariableName%&#062; right where I wanted JIM JONES to be. Also, note that &#060;%=VariableName%&#062; is synonymous to &#060;% Response.Write variableName %&#062;<BR><BR>Happy Programming, and be sure to read that article! :-)

  3. #3
    Vipul Desai Guest

    Default RE: Mixing Session Level Vars With Javascript

    Thanks for the help. In essence, from what you gave me, I can read server side variables within Javascript, but for me to change the values (i.e. write to them), I must make a trip to the server. Is this correct? I have read privelege at the client side, but I do not have the ability to change server side variables at the client-side. <BR><BR>&#062;&#062; Thanks,<BR><BR> Vipul

  4. #4
    Mark Hoffman Guest

    Default RE: Mixing Session Level Vars With Javascript

    The previous poster gave the link to the article, but I&#039ll summarize:<BR><BR>Session variables are stored on the server.<BR>Javascript variables are stored on the client, ie the web browser. Unless otherwise specified with RUNAT, Javascript is executed on the user&#039s machine.<BR><BR>Therefore, you aren&#039t able to use the client side Javascript variables on the server, since the server isn&#039t even aware of their existence.<BR><BR>Mark Hoffman<BR>Satama USA, Inc.<BR>mark.hoffman@satamausa.com<BR><BR>

Posting Permissions

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