Help with code - rounded tables - Posted (1031 Views)
Junior Member
TastyNutz
Posts: 251
251
I'm experimenting with adding rounded tables to my site. Rather than trying to change the existing tables, I have created functions to start and stop a table with rounded corners. I then use these functions to "wrap" my existing tables with a thin, rounded border.
Code:

<% 
'##############################################
'## Rounded Tables MOD ##
'##############################################

function StartRndTables(byval Width)
If strSiteRoundedCorners = "1" then
%>
<table width=<%=Width%> border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="16"><img src="images/top_lef.gif" width="16" height="16"></td>
<td height="16" background="images/top_mid.gif"><img src="images/top_mid.gif" width="16" height="16"></td>
<td width="20"><img src="images/top_rig.gif" width="20" height="16"></td>
</tr>
<tr>
<td width="14" background="images/cen_lef.gif"><img src="images/cen_lef.gif" width="14" height="11"></td>
<td >
<%
end if
end function

function EndRndTables
If strSiteRoundedCorners = "1" then
%>
<td width="20" background="images/cen_rig.gif"><img src="images/cen_rig.gif" width="20" height="11"></td>
</tr>
<tr>
<td width="16" height="16"><img src="images/bot_lef.gif" width="16" height="16"></td>
<td height="16" background="images/bot_mid.gif"><img src="images/bot_mid.gif" width="16" height="16"></td>
<td width="20" height="16"><img src="images/bot_rig.gif" width="20" height="16"></td>
</tr>
</table>
<%
end if
End function
%>
You can see how that looks HERE.
I'm pleased with the effect, but my site has additional "themes" and although the rounded table images have transparency, they don't look good on darker backgrounds. So, I want to pull different images depending on the theme. Seems like it should be simple... use "getCurrentIcon" to display the images that correspond to the selected theme. It SHOULD be simple, but I can't get it right.
I can pull the images, but my problem is getting the top/bottom and side images to become the cell background so that it "tiles" and fills the cell, however large the table is.
The functions below are my attempt to rewrite using ASP, but of course "background" doesn't work here. Can someone help me get this right?
Code:

<% 
'##############################################
'## Rounded Tables MOD ##
'##############################################

function StartRndTables(byval Width)
If strSiteRoundedCorners = "1" then

Response.write "<table width="""& Width &""" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""16"">" & getCurrentIcon(strTopLeft,"","") & "</td>" & vbnewline & _
"<td height=""16"" background=""" & getCurrentIcon(strTopMid,"","") & getCurrentIcon(strTopMid,"","") & "</td>" & vbnewline & _
"<td width=""20"">" & getCurrentIcon(strTopRight,"","") & "</td>" & vbnewline & _
"</tr>" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""14"" background=""" & getCurrentIcon(strCenLeft,"","") & getCurrentIcon(strCenLeft,"","") & "</td>" & vbnewline & _
"<td>" & vbnewline

end if
end function

function EndRndTables
If strSiteRoundedCorners = "1" then

Response.write "<td width=""20"" background=""" & getCurrentIcon(strCenRight,"","") & getCurrentIcon(strCenRight,"","") & "</td>" & vbnewline & _
"</tr>" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""16"" height=""16"">" & getCurrentIcon(strBotLeft,"","align=""absmiddle""") & "</td>" & vbnewline & _
"<td height=""16"" background=""" & getCurrentIcon(strBotMid,"","") & getCurrentIcon(strBotMid,"","") & "</td>" & vbnewline & _
"<td width=""20"" height=""16"">" & getCurrentIcon(strBotRight,"","align=""absmiddle""") & "</td>" & vbnewline & _
"</tr>" & vbnewline & _
"</table>" & vbnewline

end if
End function
%>
<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Senior Member
MaD2ko0l
Posts: 1053
1053
hiya
shouldnt the background properties be like this(added the bitz in red)

Code:

      "<td width=""14"" background=""" & getCurrentIcon(strCenLeft,"","") & ">" & getCurrentIcon(strCenLeft,"","") & "</td>" & vbnewline & _

it seems like u r calling the images twice with out closing the starting <td> tag so when viewing it as normal html (ie right click > view source) it woudl look somthign liek this

Code:

      <td height="16" background="images/bot_mid.gif"<img src="images/bot_mid.gif" width="16" height="16"></td>   



hey wait...just looked at the inc_iconfiles.asp file and u wont be able to use the getCurrentIcon function to display the image because it add the whole img tags (eg. <img src="filename.gif">) rather than just the file name

<
© 1999-2010 MaD2ko0l
Posted
Junior Member
TastyNutz
Posts: 251
251
Thank you. I got it working, thanks to your clue. Sometimes I need someone to remind me of the obvious. That's why I come here. bigsmile
The functions:
Code:

<% 
'##############################################
'## Rounded Tables MOD ##
' by TastyNutz@powerquad.net
'##############################################

function StartRndTables(byval Width)
If strSiteRoundedCorners = "1" then

Response.write "<table width="""& Width &""" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""1"">" & getCurrentIcon(strTopLeft,"","") & "</td>" & vbnewline & _
"<td height=""1"" """ & strTopMidBG & """></td>" & vbnewline & _
"<td width=""1"">" & getCurrentIcon(strTopRight,"","") & "</td>" & vbnewline & _
"</tr>" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""1"" """ & strCenLeftBG & """></td>" & vbnewline & _
"<td>" & vbnewline

end if
end function


function EndRndTables
If strSiteRoundedCorners = "1" then

Response.write "<td width=""1"" """ & strCenRightBG & """></td>" & vbnewline & _
"</tr>" & vbnewline & _
"<tr>" & vbnewline & _
"<td width=""1"" >" & getCurrentIcon(strBotLeft,"","") & "</td>" & vbnewline & _
"<td height=""1"" """ & strBotMidBG & """></td>" & vbnewline & _
"<td width=""1"" >" & getCurrentIcon(strBotRight,"","") & "</td>" & vbnewline & _
"</tr>" & vbnewline & _
"</table>" & vbnewline

end if
End function
%>

And to each of my theme files I add:

Code:

'##############################################
'## Rounded Tables MOD ##
strBotLeft = "themes/hi_tech/bot_lef.gif||"
strBotRight = "themes/hi_tech/bot_rig.gif||"
strBotMid = "themes/hi_tech/bot_mid.gif"
strCenLeft = "themes/hi_tech/cen_lef.gif"
strCenRight = "themes/hi_tech/cen_rig.gif"
strTopLeft = "themes/hi_tech/top_lef.gif||"
strTopRight = "themes/hi_tech/top_rig.gif||"
strTopMid = "themes/hi_tech/top_mid.gif"
strCenLeftBG = " background=""" & strImageURL & strCenLeft
strTopMidBG = " background=""" & strImageURL & strTopMid
strBotMidBG = " background=""" & strImageURL & strBotMid
strCenRightBG = " background=""" & strImageURL & strCenRight
'##############################################

Now I'm going to sleep. sleepy Tomorrow I'll create some new images.<
 
You Must enter a message