PDA

Click to See Complete Forum and Search --> : setup headings


Steven McGarva
Oct 13th, 2000, 05:11 AM
I am new to HTML, can anyone advise me on how to fix this bit of code? I need to set up Column headings on a page and the following code does it (incorrectly). How does this work, how can I align as I need to? Any other tips or advice.

My data will also need to be aligned but if I can understand the headings, then I should be able to extrapolate into the data columns.


'Write headings
'Write First Row of Headings
TabOpenRow
TabWriteCell "",3,"","",0," "
TabWriteCell "",2,"center","Arial",2,"<strong>Readings</strong>"
TabWriteCell "",2,"","",0,"&nbsp;"
TabWriteCell "",1,"right","Arial",2,"<strong>Units</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",4,"right","Arial",2,"<strong>Units</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>Unit Price</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>Discount</strong>"
TabWriteCell "",1,"centre","Arial",2,"<strong>Charge</strong>"
TabCloseRow
'Write Second Row of Headings
TabOpenRow
TabWriteCell "",3,"","",0,"&nbsp;"
TabWriteCell "",1,"centre","Arial",2,"<strong>Present</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",1,"centre","Arial",2,"<strong>Previous</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",1,"right","Arial",2,"<strong>Used</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",4,"right","Arial",2,"<strong>Charged</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>(£)</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>(£)</strong>"
TabWriteCell "",1,"centre","Arial",2,"<strong>(£)</strong>"
TabCloseRow

monte96
Oct 13th, 2000, 09:29 AM
You'd need to post the function your calling in your code to see what your doing. I would not recomend building tables this way. It will be very slow and inefficient to have a function call for each cell.

Steven McGarva
Oct 13th, 2000, 09:33 AM
Sorry, I should have posted it - here it is.

If it is not good to make this function call what else can I do? There is a lot of this kind of formating (ie for data below columns etc). And its used to set out other parts of the pages.



Sub TabWriteCell(pstrWidth,pintColSpan,pstrAlign,pstrFontFace,pintFontSize,pstrContent)
Response.Write("<td")
If pstrWidth <> "" Then Response.Write(" width='" & pstrWidth &"'")
If pintColSpan <> 1 Then Response.Write(" colspan='" & pintColSpan & "'")
If pstrAlign <> "" Then Response.Write(" align='" & pstrAlign &"'")
Response.Write(">")
If pstrFontFace <> "" Then Response.Write("<font face='" & pstrFontFace &"' size='" & pintFontSize & "'>")
Response.Write(pstrContent)
If pstrFontFace <> "" Then Response.Write("</font>")
Response.Write("</td>")
End Sub

monte96
Oct 13th, 2000, 10:06 AM
<HTML>
<BODY>
<TABLE border=1>
<TR><%
TabWriteCell "",3,"","",0,"&nbsp;"
TabWriteCell "",3,"center","Arial",2,"<strong>Readings</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",1,"right","Arial",2,"<strong>Units</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",4,"right","Arial",2,"<strong>Units</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>Unit Price</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>Discount</strong>"
TabWriteCell "",1,"centre","Arial",2,"<strong>Charge</strong>"
%></TR>
<TR><%
TabWriteCell "",3,"","",0,"&nbsp;"
TabWriteCell "",1,"centre","Arial",2,"<strong>Present</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",1,"centre","Arial",2,"<strong>Previous</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",1,"right","Arial",2,"<strong>Used</strong>"
TabWriteCell "",1,"","",0,"&nbsp;"
TabWriteCell "",4,"right","Arial",2,"<strong>Charged</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>(£)</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>(£)</strong>"
TabWriteCell "",1,"right","Arial",2,"<strong>(£)</strong>"
%></TR>
</TABLE>
</BODY>
</HTML>

<%
Sub TabWriteCell(pstrWidth,pintColSpan,pstrAlign,pstrFontFace,pintFontSize,pstrContent)
Response.Write("<td")
If pstrWidth <> "" Then Response.Write(" width='" & pstrWidth &"'")
If pintColSpan <> 1 Then Response.Write(" colspan='" & pintColSpan & "'")
If pstrAlign <> "" Then Response.Write(" align='" & pstrAlign &"'")
Response.Write(">")
If pstrFontFace <> "" Then Response.Write("<font face='" & pstrFontFace &"' size='" & pintFontSize & "'>")
Response.Write(pstrContent)
If pstrFontFace <> "" Then Response.Write("</font>")
Response.Write("</td>")
End Sub
%>



If your doing conditional formatting, the functions may make sense but it will still be slower. You won't notice the slowdown until you have lots of data to put in the table. Looks like you had your colspan parameters a little mixed up and just had the wrong number of columns for everything to line up. If you turn the border on, you can see this, then once you have it set up the way you want, set border=0.

Steven McGarva
Oct 13th, 2000, 10:16 AM
Big thanks monte96, thanks for making the effort to suss
my problem then offer a solution. Cheers