p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Pro Code Clinic
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 4th, 2003, 03:27 PM
Registered User
Points: 7, Level: 1
Points: 7, Level: 1 Points: 7, Level: 1 Points: 7, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default use vbscript declared variable in asp

Hi i need to use a variable declared under the <script> tag later in my asp page. Code follows:

<%@LANGUAGE=VBSCRIPT%>
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</head>

<script language=vbscript>
dim myvar
myvar = "hello"
</script>

<body>
<br>
<%
response.write (myvar)
%>

</body>

</HTML>

how do i use the myvar variable declared under the <script> tag under the asp <% %> tags. Thanks George
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #2 (permalink)  
Old June 4th, 2003, 07:34 PM
Friend of Wrox
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The code in the script tag is running on the *client*. The code running between the <%%> (asp) is running on the *server*. You can't just transfer the variables like that. To send the value to the server you must either:
- Create a form, add the value to one of the fields on the form and POST the form
- Add it to a querystring (GET) and make a new request to the server.

There are other options but these are the most straightforward. I can provide further details.

regards
David Cameron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #3 (permalink)  
Old June 5th, 2003, 07:39 AM
Registered User
Points: 7, Level: 1
Points: 7, Level: 1 Points: 7, Level: 1 Points: 7, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply david, I know how to use the two solutions you suggested I was hoping for something else please let me know of any other solutions that may work. (any language) I'm leaning towards creating a session variable then calling its value whenever i need it. Thanks George
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #4 (permalink)  
Old June 5th, 2003, 07:33 PM
Friend of Wrox
Points: 437, Level: 7
Points: 437, Level: 7 Points: 437, Level: 7 Points: 437, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't avoid a trip to the server and sending the variable (either by GET or POST) is the most convenient way to do this.

regards
David Cameron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change ASP variable in VBScript jimusa Classic ASP Basics 1 August 13th, 2008 08:08 PM
vbscript + xsl:variable lscjtw XSLT 9 August 2nd, 2007 12:44 PM
How To Pass Javascript variable to vbscript pbcatan Classic ASP Databases 1 December 18th, 2006 08:42 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 08:35 AM
Tranfer variable from server to vbscript thanhhai_ktm ASP Pro Code Clinic 1 November 19th, 2004 12:55 AM



All times are GMT -4. The time now is 12:21 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc