Session Variable to change image

liunx

Guest
So sorry, just saw the request that .asp questions be asked in a particular forum. I ask that a mod move this.

My apologies,

Hello,

I'm new to the board and in need of assistance. Any thoughts are greatly appreciated as this has me stumped.

What I would like is to have a session variable which will change a select image w/each page. For instance, you are on one page, and select another, an image on the page will change slightly.

The site I'm working on is written in .asp and all pages use an include file for basic operation. Any thoughts?

-BobbyMillions of ways to do that - all depends on your need.

I'm guessing the best way would be to store the file name of the image itself in your session variable.

From what you said, you're using one file included into every page for your basic functions, so you could just declare a variable in there and use that rather than a Session variable.


dim thisUrl, strImage

thisUrl = lcase(request.ServerVariables("URL"))
while(instr(thisUrl,"/") > 0)
thisUrl = mid(thisUrl,instr(thisUrl,"/")+1)
wend

select case thisUrl
case "index.asp"
strImage = "home.gif"
case "search.asp"
strImage = "magnify_glass.gif"
case else
strImage = "logo.gif"
end select


so that would be the code in your included file...and then in, for instance, index.asp you'd have....


<!--#include file="thatFile.asp"-->

<img src=http://www.htmlforums.com/archive/index.php/"images/<%=strImage%>">



that should do it.

If you need the Session variable then it's pretty easy to just do that code when you know the image will change and then set the Session variable and then you can just use that if you're not going to need to change images on every page.Originally posted by robwdav
So sorry, just saw the request that .asp questions be asked in a particular forum. I ask that a mod move this.

My apologies,



Was replying/moving while you were editing I guess :P

'sall good but I'll just put this out here as to not to confuse some poor mod (you know they're not the quickest :D oh, wait, that includes me......hmmmmmm....okay so SOME of the mods aren't the quickest :P)Great, thanks for the help! I'm a lil unclear on your code, by "thisurl" do i input the url or leave as you've written. I'm going to try and include some of my code so you may see. Pleas let me know if it's unclear. I also forgot to mention. The image that should be changed is in a particular layer. Does that complicate things?

Thanks so much for the quick answer!

code:
<center>
<div align="center" id="BG" style="position:relative; width:760px; height:570px; z-index:1">
<div id="Layer1" style="position:absolute; left:5px; top:1px; width:750px; height:76px; z-index:2"><img src=http://www.htmlforums.com/archive/index.php/"Images/banner.jpg" width="750" height="76" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="25,35,95,56" href=http://www.htmlforums.com/archive/index.php/"/index.asp">
<area shape="rect" coords="112,35,182,58" href=http://www.htmlforums.com/archive/index.php/"/philo.asp">
<area shape="rect" coords="202,35,272,57" href=http://www.htmlforums.com/archive/index.php/"service.asp">
<area shape="rect" coords="287,34,363,57" href=http://www.htmlforums.com/archive/index.php/"/remit.asp">
<area shape="rect" coords="377,35,452,58" href=http://www.htmlforums.com/archive/index.php/"/forms.asp">
<area shape="rect" coords="470,35,539,57" href=http://www.htmlforums.com/archive/index.php/"/clients.asp">
<area shape="rect" coords="558,36,631,57" href=http://www.htmlforums.com/archive/index.php/"/staff.asp">
<area shape="rect" coords="650,36,724,56" href=http://www.htmlforums.com/archive/index.php/"/contact.asp">
</map>
</div>

that layer holds the image which will change w/each page.*replied to your PM*
 
Back
Top