Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show image based on value 1

Status
Not open for further replies.

OnAFan

Technical User
Mar 13, 2002
120
US
Hello Everyone, Here's my question...
I have a page with cells. In the cells, there are going to be 4 assigned values(via ASP) (Working, Broken, Degraded, N/A) Right now, for each cell I pull in the actual values from the DB. How would I change it to pull in a graphic based on value (ie. If it is working, I just want green.jpg not the word Working / for Broken I want red.jpg, etc.) This is probably something very simple, but my brain is fried right now and I am fairly new to Javascript. Thanks for any help.
Terry
 
I'll write up this pseudo-ASP code using server side JScript
Code:
<%
var dbItem;
oRS.Source = "select whatever from database where something = somethingelse";
oRS.Open();
while(!oRS.EOF) {
   dbItem = String(oRS.Fields("whatever").value);
   if (dbItem == "Working") {
      Response.Write("<td><img src='working.jpg'></td>");
   }
   else if (dbItem == "Broken") {
      Response.Write("<td><img src='broken.jpg'></td>");
   }
   else if (dbItem == "Degraded") {
      Response.Write("<td><img src='degraded.jpg'></td>");
   }
   else if (dbItem == "N/A") {
      Response.Write("<td><img src='na.jpg'></td>");
   }
   oRS.MoveNext;
}   
oRS.Close();
%>

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top