Dynamic Variable Names

Is it possible to take the values of two variables, and put them together to form a third variable name?
For instance, lets say I have the following variables:
(I am leaving off quotes to prevent problems with the form)

animalA = cat
animalB = dog
animalC = fish
animalD = bird
can I then add two values together to crreate a third variable name?

For instance, can I add animalA & animalC to create the variable named catfish, which according to the list below has a value of 12?

catfish = 12
birddog = 13
catdog = 14
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can't do that in vbscript, unless I'm sorely mistaken, but in javascript you can;

function dothing(){
      var a='dog';
      var b='cat';
      eval('var '+a+b+'=\'I like puppies\';')

but I suppose you use vbscript for your asp, right?
How about this ?

animalA = "cat"
animalB = "dog"
animalC = "fish"
animalD = "bird"
CombinedAnimal = animalA & animalC
response.write "Valeu " & CombinedAnimal
response.write "Vale " & CombinedAnimal
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

nistmaruAuthor Commented:
Yes, I use VBScript, but what about a mix of the two? Would it work if the list of variables was in a javascript include file?

I am using the file system object to return a list of all PDF files in a folder where the naming convention is the product part number. I then create a hyperlink to each pdf file, but rather than the file name being the hyperlink, I want touse a descriptive title.

Basically, I have a script that where each PDF file will have a corresponding title that resides with a list of all titles in an include file.

Lets call them abc.pdf and xyz.pdf. The titles will be in the include file like this:
ttl_abc = 'High Quality Machine Parts'
ttl_xyz = 'High Temp Materials'

For instance, when the file 'abc.pdf' is returned, it the script will check the list in the include file to see if there is a value for ttl_abc, and if there is, then it will create a hyperlink to the PDF file using the title as the link. If there was no value for ttl_abc, then it will create a link to the PDF using the PDF filename as the link.

You can use session object for this.

animalA = "cat"
animalB = "dog"
animalC = "fish"
animalD = bird

session(animalA & animalC) = 12

now you can do...
Response.Write session("catfish")
nistmaruAuthor Commented:
Using the session object will work, but I will have dozens, if not hundreds of files, won't that eat up system resources?
Why dynamic variables?
You have a list of files and their titles like this?
ttl_abc = 'High Quality Machine Parts'
ttl_xyz = 'High Temp Materials'

You use FSO to get a list of all the files in a directory.  So it should be a simple case, as in your example, of....
   ttl_abc = 'High Quality Machine Parts'
   ttl_xyz = 'High Temp Materials'
   ... etc for all the descriptive titles

   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(folderspec)
   Set fc = f.Files
   For Each x in fc
        response.write "<a href=" & x.name & ">" & "ttl_" & temp(0) & "</a><br>"
   Set fso=nothing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Amend this line
response.write "<a href=" & x.name & ">" & "ttl_" & temp(0) & "</a><br>"


response.write "<a href=" & x.name & ">" & eval("ttl_" & temp(0)) & "</a><br>"
nistmaruAuthor Commented:
This worked perfectly, thank you very much!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.