[thelist] ASP Problem - Pulling schedules items in a loop?

Ken Schaefer Ken at adOpenStatic.com
Mon Jun 4 19:48:09 CDT 2007


Jon,

> Basically, right now, it pulls one item: Whichever is in the date match.

It pulls what? From where? What exactly are you talking about here?

At the moment you have some inline sequential code. It looks for matching
conditions, and it sets some variables. I don't understand why you think it
would do anything else? Setting a "showall" variable isn't going to help,
because you only have two variables, and you're just overwriting the value of
those variables as you flow through your code.

>From what I *think* you are trying to do (and I'm making a big assumption
here) - is that you have a list of possible links. You either want to display
just the link that matches the current data (per your existing code) -or- you
want to display all possible links.

In that situation, I would suggest you refactor your code. Store the links
and their criteria somewhere else (e.g. database, hashtable etc). Then you
can much more easily choose to display all links (by just ignoring the
criteria) or pull back the record (database) or key/value pair (hash table)
that matches your criteria (Date()).

But let's suppose you want to keep what you have. Here is an option:

- create an array or hashtable (Dictionary object) to store your links and
images. As you flow through your code, you add elements to the array or hash
table. This basically replaces the code here:

<%
imgLink = "this.asp"
imgSrc = "this.jpg"
%>

With something like:

<%
myArray(i,1) = "this.asp"
myArray(i,2) = "this.jpg"
%>

And then, in your presentation section, you just iterate your array to write
out your links:

<%= WriteLinks(myArray) %>
'
'
'
<%
Sub WriteLinks( _
	byVal myArray _
	)

	If isArray(myArray) then

		For i = 0 to UBound(myArray, 1) -1

			Response.Write("<a href=""" & myArray(i,1) & """><img
src=""" & myArray(i,2) & """></a>"

		Next

	Else

		Response.Write("no matching links")

	End If

End Sub
%>


Cheers
Ken



-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Jon Hughes
Sent: Tuesday, 5 June 2007 1:11 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] ASP Problem - Pulling schedules items in a loop?

Ken,

Basically, right now, it pulls one item: Whichever is in the date match.

What I want to do, is output ALL items in the schedule.asp file, so I
can return things in all dates.

Schedule.asp:
startdate=DateValue("5/29/2007")
enddate=DateValue("6/10/2007")
if (date() >= StartDate and date() <= EndDate) or showall = "1" then
imgLink = "this.asp"
imgSrc = "this.jpg"
end if

startdate=DateValue("6/11/2007")
enddate=DateValue("6/21/2007")
if (date() >= StartDate and date() <= EndDate) or showall = "1" then
imgLink = "that.asp"
imgSrc = "that.jpg"
end if

---

Single Pull:
<a href="<%=imgLink%>"><img src="<%=imgSrc%>"></a>

ALL Pull (NOT WORKING CODE):

<a href="<%=imgLink%>"><img src="<%=imgSrc%>"></a> (this is "this")
<a href="<%=imgLink%>"><img src="<%=imgSrc%>"></a> (this is "that")

Basically, I want to do that... Pull everything in the same file,
regardless of the date, without setting different variables for each.


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Ken Schaefer
Sent: Friday, June 01, 2007 10:39 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] ASP Problem - Pulling schedules items in a loop?

Hi Jon,

Could you explain exactly what you're trying to accomplish? When you say
"how
do I pull ALL of these?" - all of what, exactly?

Cheers
Ken 
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 



More information about the thelist mailing list