|
 |
asp_databases thread: Getting table-layout right through ASP-loop
Message #1 by "Carolien Latupeirissa" <clatupeirissa@h...> on Wed, 28 Mar 2001 13:41:07 +0200
|
|
Hi,
I have a problem getting my table layout right through the ASP Loop ( as
seen in code).
I tried <td width=#> and <td width=#%> and just <td>. But the cells are of
different sizes in every record.
I don't know what to do now, can anybody help me?
Kind regards,
Carolien
PS code: (I use the line item to split the tables, so every order is in a
different little tables (which all should have the same size))
<%
Dim objConn
Dim objOrderstatusRS
Dim strGetOrderstatus
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.Open "DSN=Orderstatus"
Set objOrderstatusRS = Server.CreateObject ("ADODB.Recordset")
strGetOrderstatus = "SELECT * FROM qryAll"
Set objOrderstatusRS = objConn.Execute(strGetOrderstatus)
While Not objOrderstatusRS.EOF
strLineItem = objOrderstatusRS.Fields("LineItem")
If strLineItem=1 Then
Response.Write "<TABLE cellspacing=0 cellpadding=0 width=580 border=1><tr>"
Response.Write "<td width=50><font size=1 face=arial>Cadcode</font></td>"
Response.Write "<td width=29><font size=1 face=arial>Cad#</font></td>"
Response.Write "<td width=43><font size=1 face=arial>Supplier</font></td>"
Response.Write "<td width=43><font size=1 face=arial>Buyer</font></td>"
Response.Write "<td width=22><font size=1 face=arial>Line</font></td>"
Response.Write "<td width=56><font size=1 face=arial>Itemcode</font></td>"
Response.Write "<td width=102><font size=1
face=arial>Description</font></td>"
Response.Write "<td width=28><font size=1 face=arial>Ordered</font></td>"
Response.Write "<td width=28><font size=1 face=arial>Received</font></td>"
Response.Write "<td width=41><font size=1 face=arial>Orderdate</font></td>"
Response.Write "<td width=41><font size=1 face=arial>Duedate</font></td>"
Response.Write "<td width=34><font size=1 face=arial>Req by</font></td>"
Response.Write "<td width=28><font size=1 face=arial>Group</font></td>"
Response.Write "<td width=41><font size=1 face=arial>Ship to</font></td>"
Response.Write "<td width=28><font size=1 face=arial>Hub</font></td>"
Response.Write "<td width=55><font size=1 face=arial>Country</font></td>"
Response.Write "<td width=10><font size=1 face=arial>Comment</font></td>"
Response.Write "</tr></table>"
End If
Response.Write "<TABLE cellspacing=0 cellpadding=0 width=580 border=1>"
Response.Write "<tr bgcolor=FFFFFF>"
Response.Write "<td width=50><font size=2 face=arial>" &
objOrderstatusRS.Fields("Cadenza Code") & "</font></td>"
Response.Write "<td width=29><font size=2 face=arial>" &
objOrderstatusRS.Fields("Cadenza #") & "</font></td>"
Response.Write "<td width=43><font size=2 face=arial>" &
objOrderstatusRS.Fields("Supplier") & "</font></td>"
Response.Write "<td width=43><font size=2 face=arial>" &
objOrderstatusRS.Fields("Buyer") & "</font></td>"
Response.Write "<td width=22><font size=2 face=arial>" &
objOrderstatusRS.Fields("LineItem") & "</font></td>"
Response.Write "<td width=56><font size=2 face=arial>" &
objOrderstatusRS.Fields("Itemcode") & "</font></td>"
Response.Write "<td width=102><font size=2 face=arial>" &
objOrderstatusRS.Fields("Itemdescription") & "</font></td>"
Response.Write "<td width=28><font size=2 face=arial>" &
objOrderstatusRS.Fields("UnitsOrdered") & "</font></td>"
Response.Write "<td width=28><font size=2 face=arial>" &
objOrderstatusRS.Fields("UnitsReceived") & "</font></td>"
Response.Write "<td width=41><font size=2 face=arial>" &
objOrderstatusRS.Fields("Orderdate") & "</font></td>"
Response.Write "<td width=41><font size=2 face=arial>" &
objOrderstatusRS.Fields("Duedate") & "</font></td>"
Response.Write "<td width=34><font size=2 face=arial>" &
objOrderstatusRS.Fields("Requested by") & "</font></td>"
Response.Write "<td width=28><font size=2 face=arial>" &
objOrderstatusRS.Fields("Group/Dept") & "</font></td>"
Response.Write "<td width=41><font size=2 face=arial>" &
objOrderstatusRS.Fields("Ship to Address") & "</font></td>"
Response.Write "<td width=28><font size=2 face=arial>" &
objOrderstatusRS.Fields("Hub") & "</font></td>"
Response.Write "<td width=55><font size=2 face=arial>" &
objOrderstatusRS.Fields("Country") & "</font></td>"
Response.Write "<td width=10><font size=2 face=arial>" &
objOrderstatusRS.Fields("Comment") & "</font></td>"
Response.Write "</tr></table>"
objOrderstatusRS.MoveNext
Wend
objOrderstatusRS.Close
Set objOrderstatusRS = Nothing
objConn.Close
Set objConn = Nothing
%>
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 28 Mar 2001 23:02:24 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: I have a problem getting my table layout right through the ASP Loop ( as
: seen in code).
: I tried <td width=#> and <td width=#%> and just <td>. But the cells are of
: different sizes in every record.
: I don't know what to do now, can anybody help me?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ahh, the perennial problem of getting tables right. For ideas there is an
excellent article at www.alistapart.com on liquid table designs. (which is
adapted at my site www.adOpenStatic.com - where you'll find that the liquid
table works in both NN v3+ and IE v4+)
My suggestion?
Create your table with the width fixed (as you have done).
Put fixed widths on your tables, but have them a couple of pixels less than
what you want.
Create an empty first (or last) row. The cells in these rows should just
contain a spacer .gif, that is stretched to be the width you want the <td>
to be.
Have one extra cell column on the end with the width set to 100% to take up
any slack (NN has problems with fixed width cells since it converts the
width to a % then displays the cell, and the conversion has rounding
problems:
Also, you should *always* delimit the values of HTML attributes with ". It's
an XHTML requirement, and it's better to get into good habits early.
<table width="120">
<tr>
<td width="15"><img src="/images/spacers/ffffff.gif" height="1"
width="20"></td>
<td width="35"><img src="/images/spacers/ffffff.gif" height="1"
width="40"></td>
<td width="35"><img src="/images/spacers/ffffff.gif" height="1"
width="40"></td>
<td width="15"><img src="/images/spacers/ffffff.gif" height="1"
width="20"></td>
<td width="100%"><td>
<tr>
<!-- do recordset loop here - make sure you set the TD widths all the
way down, because NN will ignore them unless you have them for every cell in
every column you want to set -->
</table>
HTH
Cheers
Ken
Message #3 by "Carolien Latupeirissa" <clatupeirissa@h...> on Wed, 28 Mar 2001 15:23:24 +0200
|
|
Hi Ken,
Well that was a solition I could not get to by myself. Thank you!
I'm going to test it right away!
Just one question:
It may not look very bright but; what's spacer .gif? Is like the file "
.gif" that doesn't exists or do I need to create some gif-file?
And will it do if I take like 1 or 2 pixels of each cell? There will be
something between 16 and 32 pixels left for the last cell (the
width="100%"-cel).
Regards,
Carolien
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: woensdag 28 maart 2001 15:02
To: ASP Databases
Subject: [asp_databases] Re: Getting table-layout right through ASP-loop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: I have a problem getting my table layout right through the ASP Loop ( as
: seen in code).
: I tried <td width=#> and <td width=#%> and just <td>. But the cells are of
: different sizes in every record.
: I don't know what to do now, can anybody help me?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ahh, the perennial problem of getting tables right. For ideas there is an
excellent article at www.alistapart.com on liquid table designs. (which is
adapted at my site www.adOpenStatic.com - where you'll find that the liquid
table works in both NN v3+ and IE v4+)
My suggestion?
Create your table with the width fixed (as you have done).
Put fixed widths on your tables, but have them a couple of pixels less than
what you want.
Create an empty first (or last) row. The cells in these rows should just
contain a spacer .gif, that is stretched to be the width you want the <td>
to be.
Have one extra cell column on the end with the width set to 100% to take up
any slack (NN has problems with fixed width cells since it converts the
width to a % then displays the cell, and the conversion has rounding
problems:
Also, you should *always* delimit the values of HTML attributes with ". It's
an XHTML requirement, and it's better to get into good habits early.
<table width="120">
<tr>
<td width="15"><img src="/images/spacers/ffffff.gif" height="1"
width="20"></td>
<td width="35"><img src="/images/spacers/ffffff.gif" height="1"
width="40"></td>
<td width="35"><img src="/images/spacers/ffffff.gif" height="1"
width="40"></td>
<td width="15"><img src="/images/spacers/ffffff.gif" height="1"
width="20"></td>
<td width="100%"><td>
<tr>
<!-- do recordset loop here - make sure you set the TD widths all the
way down, because NN will ignore them unless you have them for every cell in
every column you want to set -->
</table>
HTH
Cheers
Ken
Message #4 by "Ken Schaefer" <ken@a...> on Fri, 30 Mar 2001 13:32:01 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Well that was a solition I could not get to by myself. Thank you!
: I'm going to test it right away!
: Just one question:
: It may not look very bright but; what's spacer .gif? Is like the file "
: .gif" that doesn't exists or do I need to create some gif-file?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yes - you need to create a 1 x 1 pixel .gif file that you will stretch
using the <img> tag to the correct height or width.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: And will it do if I take like 1 or 2 pixels of each cell? There will be
: something between 16 and 32 pixels left for the last cell (the
: width="100%"-cel).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As I said, Netscape will convert absolute values to percentages. There will
thus be rounding problems when it converts, say 20 pixels to 12.6666666%
(which becomes 13%). You'll need to experiment.
The width="100%" cell should have nothing left for it though...
Cheers
Ken
Message #5 by "Dallas Martin" <dmartin@z...> on Thu, 29 Mar 2001 23:32:35 -0500
|
|
Also, avoid using the WIDTH= attribute in the declaration of the <TABLE>.
Using the WIDTH= attribute will cause the client browser to attempt
to evenly position the columns in the table. Try this yourself. Using the
same
recordset, display it once in a table using <TABLE WIDTH="100%">
and once in a table using <TABLE>.
You'll notice the difference immediately.
hth,
Dallas Martin
----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, March 29, 2001 10:32 PM
Subject: [asp_databases] Re: Getting table-layout right through ASP-loop
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : Well that was a solition I could not get to by myself. Thank you!
> : I'm going to test it right away!
> : Just one question:
> : It may not look very bright but; what's spacer .gif? Is like the file "
> : .gif" that doesn't exists or do I need to create some gif-file?
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Yes - you need to create a 1 x 1 pixel .gif file that you will stretch
> using the <img> tag to the correct height or width.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : And will it do if I take like 1 or 2 pixels of each cell? There will be
> : something between 16 and 32 pixels left for the last cell (the
> : width="100%"-cel).
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> As I said, Netscape will convert absolute values to percentages. There
will
> thus be rounding problems when it converts, say 20 pixels to 12.6666666%
> (which becomes 13%). You'll need to experiment.
>
> The width="100%" cell should have nothing left for it though...
>
> Cheers
> Ken
>
>
>
> ---
> SoftArtisans helps developers build robust, scalable Web applications!
> Excel Web reports, charts: http://www.softartisans.com/excelwriter.html
> File uploads: http://www.softartisans.com/saf.html
> Transactional file management: http://www.softartisans.com/saf1.html
> Scalability: http://www.softartisans.com/saxsession.html
> ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html
$subst('Email.Unsub')
>
|
|
 |