webForumDet fria alternativet

olika bilder med olika bakgrundfärg

ASP

1 svar · 194 visningar · startad av nille99

Medlem sedan aug. 2002352 inlägg
Frågan#1

jag har en cell med en bild som jag kan byta ut till fem olika bilder
alla bilder har en del genomskinlig yta

sen kan jag byta ut bakgrundfärgen i olika färger

allt fungerar förutom att det blir en rad av färgen under bilderna (bara nån pixel hög...).
om jag har bara en bild så finns ej raden med


                  <td rowspan="2" align="right" id="farg" bgcolor=
				  <% if RecSet("farg1") = "" then%>""<%end if %>
				  <% if RecSet("farg1") = "#0033CC" then%>#0033CC<%end if %>
				  <% if RecSet("farg1") = "#CC6633" then%>#CC6633<%end if %>
				  <% if RecSet("farg1") = "#33CC33" then%>#33CC33<%end if %>
				  <% if RecSet("farg1") = "#FFFF00" then%>#FFFF00<%end if %>
				  <% if RecSet("farg1") = "#FF6600" then%>#FF6600<%end if %>
				  <% if RecSet("farg1") = "#FF0000" then%>#FF0000<%end if %>
				  <% if RecSet("farg1") = "#000000" then%>#000000<%end if %>
				  <% if RecSet("farg1") = "#FFFFFF" then%>#FFFFFF<%end if %>>
				
				<img id="bild_1hy" src="../images/lbhytt.gif" width="46" height="86" 
				<% if RecSet("biltyp") = "Lastbil" or IsNull(RecSet("biltyp")) then
				else%> style="display:none;"
				<% end if %>>
				<img id="bild_2hy" src="../images/lbhytt.gif" width="46" height="86"
				<% if RecSet("biltyp") = "Lastbil + släp" then
				else%> style="display:none;"
				<% end if %>>
				<img id="bild_3hy" src="../images/llbhytt.gif" width="65" height="86"
				<% if RecSet("biltyp") = "Latt_Lastbil" then
				else%> style="display:none;"
				<% end if %>>
				<img id="bild_4hy" src="../images/lbhytt.gif" width="80" height="86"
				<% if RecSet("biltyp") = "Skåpbil/van" then
				else%> style="display:none;"
				<% end if %>>
				<img id="bild_5hy" src="../images/slap1.gif" width="20" height="86"
				<% if RecSet("biltyp") = "släpCE" then
				else%> style="display:none;"
				<% end if %>></td>
Medlem sedan dec. 19998 577 inlägg
#2

Man kan ju självklart göra på många sätt, kolla i html-koden som generaras så kan du hittar felet. :)

Tog mig friheten att "komprimera" din kod, hoppas du inte tar illa upp:

<%
arrStyles = array("", "", "", "", "")

for i = 0 to ubound( arrStyles )
  arrStyles(i) = "style='display:none;"
next

strBilTyp = RecSet("biltyp")
select case strBilTyp
  case "Lastbil"
    arrStyles(0) = ""
  case "Lastbil + släp"
    arrStyles(1) = ""
  case "Latt_Lastbil"
    arrStyles(2) = ""
  case "Skåpbil/van"
    arrStyles(3) = ""
  case "släpCE"
    arrStyles(4) = ""
end select
%>

<td rowspan="2" align="right" id="farg" bgcolor="<%=RecSet("farg1")%>">
<img id="bild_1hy" src="../images/lbhytt.gif" width="46" height="86" <%=arrStyles(0)%>>
<img id="bild_2hy" src="../images/lbhytt.gif" width="46" height="86" <%=arrStyles(1)%>>
<img id="bild_3hy" src="../images/llbhytt.gif" width="65" height="86" <%=arrStyles(2)%>>
<img id="bild_4hy" src="../images/lbhytt.gif" width="80" height="86" <%=arrStyles(3)%>>
<img id="bild_5hy" src="../images/slap1.gif" width="20" height="86" <%=arrStyles(4)%>></td>
262 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
129 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
124 ms — ändringar (db)