PDA

View Full Version : Dynamic image naming - by page filename


mattboy_slim
04-03-2003, 10:58 PM
Is it possible to dynamically name an image by the page filename.

Example:

I have the following:

<img src="images/header_body-contactus.jpg" width="300" height="25">


The filename that the above line is on is named contactus.asp. Could I replace the 'contactus' on the img src with a variable, which would look at the filename?
--------------------------------------

Thanks fellas'

Matt

Mhtml
04-04-2003, 04:57 AM
Hmm... The tough bit of this is getting the page file name without the rest of it's path. I don't think there is a servervariable for it so I'd do it like this:

FileName = Request.ServerVariables("URL")
FileName = strReverse(FileName)
lenP = instr(FileName, "/")
FileName = Left(FileName, lenP-1)
FileName = strReverse(FileName)
lenP = Len(FileName)
FileName = Left(FileName, lenP-4)


Then you call it like this:

<img src="header_body-<%=FileName%>.jpg" width="300" height="25"/>