Re: ASP Loop in wrong place????

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Fawke101 (guy_at_ANTIbradflack.SPAMcom)
Date: 03/29/04


Date: Mon, 29 Mar 2004 17:06:23 +0100

OK thanks for that,
All working now.

I have been using DW since i started web development, and i agree. As soon
as you have to start delving around in the code it looks well messy.
I managed to sort it eventually by editing my current code. Rather than
re-writing all my pages.
Thanks however as i will build my ASP apps dynamically in the future. I am
new to ASP so apologies for appearing nieve.

Thanks again

--
Fawke
Please remove ANTI and SPAM
from my email address before emailing me.
www.bradflack.com
"Jeff Cochran" <jcochran.nospam@naplesgov.com> wrote in message
news:4063260f.10912521@msnews.microsoft.com...
> 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: ASP Loop in wrong place????
    ... below is the code for the entire table (inc. ASP functions) ... face="Verdana, Arial, Helvetica, sans-serif"> ... >>the column data and the 3rd is where the loop for the SQL statement lies. ...
    (microsoft.public.inetserver.asp.general)
  • Re: ASP, looping, and stored procedures.... error 800a0bb9 ...
    ... > page PER loop. ... The looping goes by month from and to dates selected ... > In pure ASP the page takes about 15 seconds. ... > Oh, and by the way, the test box has SQL server and IIS on it. ...
    (microsoft.public.inetserver.asp.db)
  • Re: CE5 ASP - strange error message on Response.Flush
    ... For an ASP page stuck in a loop, there's no way for HTTPD to stop it because ... I guess CE HTTPD uses a different error message from IIS, ...
    (microsoft.public.windowsce.platbuilder)
  • Dont understand flow using xmlhttp
    ... I'm building a simple newsletter application using Classic ASP. ... loop through the array and for each e-mail address do a http ... Is there a way of not continuing the loop until the response has ... var aList = new Array; ...
    (comp.lang.javascript)
  • multiple recordset error trapping
    ... The stored procedure has internal error checking so that it ... thought was that it wold be similar in the recordset returned to the ASP ... response.write "1st record set" ... Microsoft OLE DB Provider for ODBC Drivers ...
    (microsoft.public.scripting.vbscript)