Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2003, 02:27 PM
Registered User
 
Join Date: Jun 2003
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
 
Old June 4th, 2003, 06:34 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old June 5th, 2003, 06:39 AM
Registered User
 
Join Date: Jun 2003
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
 
Old June 5th, 2003, 06:33 PM
Friend of Wrox
 
Join Date: Jun 2003
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





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change ASP variable in VBScript jimusa Classic ASP Basics 1 August 13th, 2008 07:08 PM
vbscript + xsl:variable lscjtw XSLT 9 August 2nd, 2007 11:44 AM
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 07:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.