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 June 13th, 2006, 08:58 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Joining 2 variables together for one name

Hi there

I was wondering if anyone could help me. I'm pretty sure it's something really basic but I've been scratching my head for a while now!

I have an update process page, with one section of code being:

Dim Command1__content_title
Command1__content_title = ""
if(Request("content_title") <> "") then Command1__content_title = Request("content_title")

I then have one for Command1__content_title2 (which follows the same format) and this format continues up to Command1__content_title8.

So, i thought i'd do a loop around the 2 - 8 names variables...

Dim i
for i = 2 to 8

Dim Command1__content_title & i
Command1__content_title & i = ""
if(Request("content_title" & i) <> "") then Command1__content_title & i = Request("content_title" & i)

next

BUT i'm getting an error message saying that a names being redefined (assume this is the Command1__content_title part of my loop bit)

So, what am I doing wrong with the naming of my variable to get the Command1__content_title & i to come out as Command1__content_title2, Command1__content_title3 etc?

Thanks in advance

Lucy xx

 
Old June 13th, 2006, 10:01 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Lucy,

You can use the Execute method to run dynamic code. Not a big fan myself, but it's possible...
Code:
<%
Dim test1: test1 = "Hello"
Dim test2: test2 = "World"
Dim test3: test3 = "!!!"
Dim i
For i = 1 To 3
    Execute "Response.Write test" & i & " & "" """
Next
%>
HTH,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
Joining Two DataSets YiannisF General .NET 4 October 30th, 2008 06:38 AM
joining tables pit_bait SQL Language 2 September 28th, 2007 07:29 AM
Joining Three Tables Alexpizzoferro Classic ASP Databases 5 September 1st, 2006 04:08 PM
XSLT: Joining params with Variables shasto100 XSLT 2 April 24th, 2006 07:15 AM
Joining two tables rajustha SQL Server 2000 1 December 7th, 2003 07:38 AM





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