Current location: Hot Scripts Forums » Programming Languages » ASP » Call a variable name dynamically


Call a variable name dynamically

Reply
  #1 (permalink)  
Old 11-06-03, 03:45 PM
Kenrette Kenrette is offline
New Member
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Call a variable name dynamically

This is probably an easy one for you experts out there...I am trying to assign a value to a variable after selecting the right variable name based on the values in a database query. I have about 200 variable names that I need to populate so I was hoping to assign their values dynamically. I can't seem to find the right syntax or method, but I am trying to do something like this:

the variable format is: category_month_color

R("prod_category") & "_" & R("month") & "_color = "#0000FF"

OR

R("prod_category")_R("month")_color = "#0000FF"

I get invalid character errors. Here is a more complete example:

dim cat1_january_color
dim cat2_january_color
dim cat1_february_color
dim cat2_february_color
dim cat1_march_color
dim cat2_march_color
...etc.

SELECT status, prod_category, month from products

While not R.EOF
If R("status") = "sold" Then
R("prod_category") & "_" & R("month") & "_color = "#0000FF"
Else
R("prod_category") & "_" & R("month") & "_color = "#CCBBFF"
End If
R.MoveNext
Wend

Thanks in advance for your time! : )
Kenrette
Reply With Quote
  #2 (permalink)  
Old 11-06-03, 06:44 PM
Stealth Stealth is offline
1337 pr0gr4mm3r
 
Join Date: Jun 2003
Location: Glasgow, Scotland
Posts: 188
Thanks: 0
Thanked 0 Times in 0 Posts
sorry but you cant do that
Reply With Quote
  #3 (permalink)  
Old 11-12-03, 09:48 AM
myLittleTools myLittleTools is offline
New Member
 
Join Date: Oct 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Kenrette
R("prod_category") & "_" & R("month") & "_color = "#0000FF"
you can use Execute method :

sStr = R("prod_category") & "_" & R("month") & "_color = """#0000FF"""
Execute(sStr)

Hope this helps !
__________________
<a href="http://www.myLittleTools.net">myLittleTools.net</a>
Leading provider of ASP applications
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Pass A Variable Into A URL... How? mchacon ASP 2 11-05-03 08:28 AM
FREE Team Speak server w/ every purchase of a Call of Duty Server twastudios General Advertisements 0 10-31-03 01:14 AM
running dll script using single http call? Bahlool HTML/XHTML/XML 0 10-11-03 03:16 AM
Call a sub from form? Tesco ASP 3 08-14-03 02:19 AM
get current file name as variable paulj000 PHP 16 07-24-03 06:37 PM


All times are GMT -5. The time now is 03:53 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.