We help IT Professionals succeed at work.

New podcast episode! Our very own Community Manager, Rob Jurd, gives his insight on the value of an online community. Listen Now!

x

Classic ASP VBScript:  How to add a blank row after every 5 records in a Repeat Region

lshane
lshane asked
on
617 Views
Last Modified: 2008-01-09
Classic ASP VBScript
MS Access
WIN XP PRO
DW MX

Hello.  I have a DW Repeat Region on a row <TR> of a table.  I would like to be able to add an empty row after every 5 records that are listed; however, I'm not sure how to do that.

Is this possible?  If so... how could I do this?


Thanks so much,
Shane
Comment
Watch Question

Can you post the relevant code please?

Author

Commented:
Hi, slamhound.  Thank you.  Yes, I just created a quick test page listing the products and their type/status.  It's just, I would like (or my admins) are requesting a blank row after every 5 listed records.  I would imagine a "Count" of some sort would have to be implemented, but I have very little of a clue how.  I am using the DWMX Repeat Region behavior.  

Here's the code:
====================================================================
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/connPMDData2_DSN.asp" -->
<%
Dim rsCParts
Dim rsCParts_numRows

Set rsCParts = Server.CreateObject("ADODB.Recordset")
rsCParts.ActiveConnection = MM_connPMDData2_DSN_STRING
rsCParts.Source = "SELECT * FROM common_parts ORDER BY cp_ID ASC"
rsCParts.CursorType = 0
rsCParts.CursorLocation = 2
rsCParts.LockType = 1
rsCParts.Open()

rsCParts_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsCParts_numRows = rsCParts_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <%
While ((Repeat1__numRows <> 0) AND (NOT rsCParts.EOF))
%>
  <tr>
    <td width="200"><%=(rsCParts.Fields.Item("cp_ID").Value)%></td>
    <td width="300"><%=(rsCParts.Fields.Item("cp_Status").Value)%></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsCParts.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
rsCParts.Close()
Set rsCParts = Nothing
%>
====================================================================

Thanks so much,
Shane
Something like this should work for you:
  <%
LineCount = 0
While ((Repeat1__numRows <> 0) AND (NOT rsCParts.EOF))
%>
  <tr>
    <td width="200"><%=(rsCParts.Fields.Item("cp_ID").Value)%></td>
    <td width="300"><%=(rsCParts.Fields.Item("cp_Status").Value)%></td>
  </tr>
  <%
LineCount = LineCount + 1
if LineCount = 5 then ' 5th row printed
%>
<tr><td colspan=9> </td></tr>
<%
LineCount = 0 ' Reset the count back to zero again for the next blank line
end if
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsCParts.MoveNext()
Wend
%>

Author

Commented:
Hi, slamhound.  Well, I tried it, but I stil just have a basic repeating region list.  It does not appear to have placed the additional row.

I am at home now, so I had to make another test page, and therefore, have a different recordset name.  I modified your suggestion to it, but still have the same result.

Here's the code now (With yours):

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/connPMDData2_DSN.asp" -->
<%
Dim rsTest
Dim rsTest_numRows

Set rsTest = Server.CreateObject("ADODB.Recordset")
rsTest.ActiveConnection = MM_connPMDData2_DSN_STRING
rsTest.Source = "SELECT * FROM supplies ORDER BY suppID ASC"
rsTest.CursorType = 0
rsTest.CursorLocation = 2
rsTest.LockType = 1
rsTest.Open()

rsTest_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsTest_numRows = rsTest_numRows + Repeat1__numRows
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<%
LineCount = 0
While ((Repeat1__numRows <> 0) AND (NOT rsTest.EOF))
%>
  <tr>
    <td width="100"><%=(rsTest.Fields.Item("suppID").Value)%></td>
    <td width="600"><%=(rsTest.Fields.Item("suppName").Value)%></td>
  </tr>
  <%
LineCount = LineCount + 1
if LineCount = 5 then ' 5th row printed
%>
<tr><td colspan=9> </td></tr>
<%
LineCount = 0 ' Reset the count back to zero again for the next blank line
end if
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsTest.MoveNext()
Wend
%>

</table>
</body>
</html>
<%
rsTest.Close()
Set rsTest = Nothing
%>



Thanks so much,
Shane
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Awesome!  Thank you!


Shane
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.