Re: ASP Loop in wrong place????

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jeff Cochran (jcochran.nospam_at_naplesgov.com)
Date: 03/25/04


Date: Thu, 25 Mar 2004 19:41:26 GMT

On Thu, 25 Mar 2004 17:14:34 -0000, "Fawke101"
<guy@ANTIbradflack.SPAMcom> wrote:

>OK, below is the code for the entire table (inc. ASP functions)
>If you build it in dreamweaver or something it should show you what its all
>about - note the extra row for the end of loop.
>Sorry, its alot of code....

I think the problem is that you have a single table sorted client side
and should have the ASP outside the table. You put the code to create
the recordset and start the loop right in a table cell, which doesn't
make sense to do. I suspect you've used a Javascript sortTable script
similar to the one at:

http://javascript.internet.com/forms/sort-data-table.html

Which unfortunately isn't written in the example to sort dynamically
derived data.

If it were me, I'd dispense with using DreamWeaver for coding since
you end up with munged code like this, along with extraneous trash
like the "<div align="left"></div>" in your first table cell, which is
absolutley useless code. Proper use of CSS would eliminate 90% of the
HTML in this code snippet as well. Most egregious is 12 lines of code
to create a table row with empty cells except for the first cell
containing the ASP "<%RS.MoveNext Loop%>".

Let's see if we can rewrite some of this code. Comments are in line,
and this replaces your entire code which I left quoted below. Watch
for possible line wrap.

---] Begin Code [---

<!--
Put the normal HTML code for starting the page here, along with
the Javascript block for the sortTable function.
-->

<!--
Use styles for the table header row and data rows, to eliminate
the redundant formatting codes. DreamWeaver does suck at producing
simple clean code.
-->

<style>

TH { color: #004080; font-size: small; font-family: "Verdana, Arial,
Helvetica, sans-serif"; font-weight: bold; }

TD { color: #000000; font-size: normal; font-family: "Verdana, Arial,
Helvetica, sans-serif";}

</style>

<%
' Get your record set before beginning to create the table
Dim RS, strArea
strArea = Replace(Session("lstArea"),"'","''")
Set RS = DataConnection.Execute("SELECT manager, all_customers,
income,
income_new_customers FROM vw_Summary_Area WHERE
vw_Summary_Area.Area='" &
strArea & "'")
%>

<!-- Create the table and header row in HTML -->

<table width="700" align="center" id="dataTable" name="dataTable">
  <tr>
    <th>Manager</th>
    <th>Total</th>
    <th>Income<br>All Clients</th>
    <th>Income<br>New</th>
  </tr>

<%
' Loop for the data rows within the table
do until RS.EOF
  ' Assign record set item to variables
  strManager = RS("manager")
  strAllCustomers = RS("all_customers")
  intIncome = formatcurrency(RS("income"),2)
  intIncomeNewCustomers = formatcurrency(RS("income_new_customers"),2)
  ' Build the rows dynamically in ASP
  Response.Write "<tr>" & VbCrLf
  Response.Write "<td><a href='summary_manager.asp?manager="
  Response.Write strManager & ">" & strManager & "</a></td>" & VbCrLf
  Response.Write "<td>" & strManager & "</td>" & VbCrLf
  Response.Write "<td>" & intIncome & "</td>" & VbCrLf
  Response.Write "<td>" & intIncomeNewCustomers & "</td>" & VbCrLf
  Response.Write "</tr>" & VbCrLf
  RS.MoveNext
Loop
%>

</table>

<!-- Finish up with HTML code to end the page -->

---] End Code [---

Note that I haven't tested this, don't know if it will format
correctly and I may have a typo in here. In otherwords, if your
system explodes in a fireball, it's not my fault you ran this without
checking it. :)

Jeff

>*****
><table width="700" align="center" id="dataTable" name="dataTable"cols="8">
> <tr>
> <td width="279"><a href="javascript: sortTable(0)"><div
>align="left"></div><font color="#004080" size="1" face="Verdana, Arial,
>Helvetica, sans-serif"><strong>Manager </strong></font></div></a></td>
> <td width="10"><div align="left"><font color="#003399" size="1"
>face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
> <td width="88"><a href="javascript: sortTable(2)"><div
>align="right"><font color="#004080" size="1" face="Verdana, Arial,
>Helvetica, sans-serif"><strong>Total</strong></font></div></a></td>
> <td width="22"><div align="left"><font color="#003399" size="1"
>face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
> <td width="15"><font color="#003399" size="1" face="Verdana,
>Arial, Helvetica, sans-serif">&nbsp;</font></td>
> <td width="116"><!---<a href="javascript: sortTable(5)">---><div
>align="right"><font color="#004080" size="1" face="Verdana, Arial,
>Helvetica, sans-serif"><strong>Income<br>
> All Clients </strong></font></div><!---</a>---></td>
> <td width="17"><font color="#003399" size="1" face="Verdana,
>Arial, Helvetica, sans-serif">&nbsp;</font></td>
> <td width="117"><!---<a href="javascript: sortTable(7)">---><div
>align="right"><font color="#004080" size="1" face="Verdana, Arial,
>Helvetica, sans-serif"><strong>Income <br>
> New</strong></font></div><!---</a>---></td>
> </tr>
> <tr>
> <td><font color="#000000" size="2" face="Verdana, Arial,
>Helvetica, sans-serif">
> <%Dim RS, strArea
>strArea = Replace(Session("lstArea"),"'","''")
>
>Set RS = DataConnection.Execute("SELECT manager, all_customers, income,
>income_new_customers FROM vw_Summary_Area WHERE vw_Summary_Area.Area='" &
>strArea & "'")
>do until RS.EOF
>%>
> <a href= "summary_manager.asp?manager=<%=RS("manager")%>">
> <% =RS("manager")%>
> </a>
> </font>
>
> </td>
> <td><font color="#000000" size="2" face="Verdana, Arial,
>Helvetica, sans-serif">&nbsp;</font></td>
> <td><div align="right"><font color="#000000" size="2"
>face="Verdana, Arial, Helvetica, sans-serif">
> <% =RS("all_customers")%>
> <em></em></font></div></td>
> <td><font color="#000000" size="2" face="Verdana, Arial,
>Helvetica, sans-serif">&nbsp;</font></td>
> <td>&nbsp;</td>
> <td><div align="right"><font color="#000000" size="2"
>face="Verdana, Arial, Helvetica, sans-serif">
> <% =formatcurrency(RS("income"),2)%>
> </font></div></td>
> <td>&nbsp;</td>
> <td><div align="right"><font color="#000000" size="2"
>face="Verdana, Arial, Helvetica, sans-serif">
> <% =formatcurrency(RS("income_new_customers"),2)%>
> </font></div></td>
> </tr>
> <tr>
> <td><font color="#000000" size="2" face="Verdana, Arial,
>Helvetica, sans-serif">
> <%RS.MoveNext
>Loop%>
> </font></td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> <td>&nbsp;</td>
> </tr>
> </table>
>*****



Relevant Pages

  • Re: Unknown IE Table Issues
    ... Dreamweaver tends to do this automatically, ... then attach all the presentation stuff via CSS. ... text in that cell to do what I want now. ... As long as the sites work and I continue to learn and work my way to ...
    (alt.html)
  • Re: Unknown IE Table Issues
    ... Dreamweaver tends to do this automatically, ... then attach all the presentation stuff via CSS. ... text in that cell to do what I want now. ... As long as the sites work and I continue to learn and work my way to ...
    (alt.html)
  • Re: Undo Missing; Copy also Missing
    ... Davoud wrote: ... the Edit Menu.... ... copied some text from a Word 2008 document to paste into a cell in ... Dreamweaver. ...
    (microsoft.public.mac.office.word)