Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 August 20th, 2004, 01:34 AM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to display variable value not variable name?

Hi all,

I am trying to use an array to hold the varable names Drop1, Drop2, Drop3, Drop4, Drop5 and Drop6. I then want to use Response.Write to display the values of the variable names which have already been input. The problem that I am getting is that when I write the array using Response.Write StrDropDownArray(1,counter) I get the variable name ond not the value of the appropriate variable. Does anyone know how that I can get the value from the variable using the array method.
The code that I am using is shown below.
Code:
<%
DIM NumberDropDowns, Drop1, Drop2, Drop3, Drop4, Drop5, Drop6, counter, StrDropDownArray

NumberDropDowns = 6

Drop1 = "Menu 1"
Drop2 = "Menu 2"
Drop3 = "Menu 3"
Drop4 = "Menu 4"
Drop5 = "Menu 5"
Drop6 = "Warranty,Tech Support,Seminars,Locations,Web Master"

REDIM StrDropDownArray(NumberDropDowns,20)
    For counter = 1 to NumberDropDowns
        StrDropDownArray(1,counter) = "Drop" & counter
    Next

    For counter = 1 to NumberDropDowns
        Response.Write "counter"& counter &" = "& StrDropDownArray(1,counter) & "<br>"
    Next    
%>
Thanks
Graham
 
Old August 20th, 2004, 02:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Graham,

You can not dynamically create variable names.

What you are doing here is creating a string "Drop" and appending another string "1","2","3"...etc.
This produces a string of "Drop1","Drop2",...etc

When you execute
Drop1 = "Menu 1"
you are storing the value "Menu 1" in an area of memory.
And you can reference that area of memeory by using the variable name Drop1

Drop1 and "Drop1" are not the same thing.


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old August 20th, 2004, 02:30 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Graham,

You can do it using the Execute method...

Code:
Call Execute("StrDropDownArray(1,counter) = Drop" & counter)
HTH,

Chris

 
Old August 24th, 2004, 09:56 PM
Registered User
 
Join Date: Jan 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi rodmcleay and Chris,
thanks for your help.
Graham

Use you brain, not your brawn!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display localization variable? toshesh ASP.NET 1.0 and 1.1 Basics 0 March 30th, 2007 12:11 PM
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
Object variable or With block variable not set tparrish VS.NET 2002/2003 3 May 22nd, 2005 07:40 AM
Can't display input variable passed on to php code mespejo Beginning PHP 2 November 25th, 2003 03:32 PM





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