Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-30-2005, 07:02 PM   PM User | #1
sitecorp
New to the CF scene

 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
sitecorp is an unknown quantity at this point
Thumbs up Assign image based on category variable value

Hi,

I have an aspx page http://www.fast-drinks.com/Categories.aspx - There are various categories eg Spirits, Wines, beer - but within each category there are sub categories eg for Spirits you have Gin, Vodka, Whiskey etc.

The Category is being displayed in the html via the variable <%=SuperCats%> (I'm presuming this is an ASP (or ASP.Net) variable - I'm new to this!). What I want to do is depending on this value to display a different image. If you go to the above page you will see a grey bar with no content about 2 inches down the page. I want to put one image in this bar if <%=SuperCats%> is Spirits and another if its Wine and another if its Champagene, and anther if its Gifts, and anotherif .........................

I am presuming a JavaScript if statement will do the job - I just don't know how to implement it as the page is being rendered, as I am relatively new to the whole web development side of things - I normally do console apps.

THis is the code black I have at the moment

<tr height="22" style="background-image:url(images/front_end_site_images/sort_bar.gif)">
<td colspan="2">

<SCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
if (<%=SuperCats%>=="Gift Ideas")
{
document.write('<img src="images/front_end_site_images/giftideas.gif">');
}
else if (<%=SuperCats%>=="Champagnes")
{
document.write('<img src="images/front_end_site_images/champagne.gif">');
}
else
{
document.write("hi...test..nothing done");
}
</SCRIPT>

<td>
</tr>

Your help is appreciated in any way shape or form.

Thanks and Best Regards
sitecorp is offline   Reply With Quote
Old 12-31-2005, 01:14 AM   PM User | #2
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,053
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
You can do this via the Select Case statement, for example:

Code:
Select Case SuperCats
   Case "Gift Ideas"
       srcImage = "images/front_end_site_images/giftideas.gif"
   Case "Champagnes'
       srcImage = "images/front_end_site_images/champagne.gif"
   Case Else
       srcImage = "images/front_end_site_images/defaultimage.gif"
End Select
Now, I'm not sure exactly where you need to put that. Is SuperCats a database lookup value that defaults to something on the page load? If so, you could put this in your Page_Load subroutine. Depends on how you want your page to function. Anyway, hope this helps.

BTW, it would be helpful if you used the forum code tags when posting code.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:58 AM.


Advertisement
Log in to turn off these ads.