• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Modify Table Display II

I previously submitted this question, and we thought the solution was identified:
I have a web page that displays fleet information from a database by district. Each district has a variable number of fleets, and each fleet has a variable number of contact lines:
  <div id="fleetInfo">
          <table>
            <% While ((Repeat2__numRows <> 0) AND (NOT rsfleetOfficers.EOF)) %>
              <tr>
                <td width="450"><%=(rsfleetOfficers.Fields.Item("fleet").Value)%></td>
                <td width="220"><%=(rsfleetOfficers.Fields.Item("name").Value)%></td>
            </tr>
              <%
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  rsfleetOfficers.MoveNext()
Wend
%>
          </table>
  </div>
Each record also contains a fleet number. I would like to create extra spacing between each fleet grouping, and/or, preferably, draw a horizontal line.

I took the provided solution and made a couple of changes:
    <div id="fleetInfo">
      <table>
        <% iFleet = rsfleetInfo.Fields.Item("fleetNo").Value %>
        <hr width=95% />
        <% While ((Repeat2__numRows <> 0) AND (NOT rsfleetInfo.EOF))
          If rsfleetInfo.Fields.Item("fleetNo").Value <> iFleet then
                iFleet = rsfleetInfo.Fields.Item("fleetNo").Value%>
                <hr width=95% />
         <% End If%>
          <tr>
            <td width=450><%=(rsfleetInfo.Fields.Item("fleet").Value)%></td>
            <td width=220><%=(rsfleetInfo.Fields.Item("name").Value)%></td>
          </tr>
          <%
        Repeat2__index=Repeat2__index+1
        Repeat2__numRows=Repeat2__numRows-1
        rsfleetInfo.MoveNext()
      Wend
      %>
      </table>
    </div>
There are no processing errors, but no matter where I put the "If" code, all the horizontal lines display first, followed by the fleet information

Now this is really weird. I just copied from the web page to show what is happening, and the pasted the information here. The horizontal lines were exactly where they are supposed to be. I also copied and pasted to Notepad and got the same results??

--------------------------------------------------------------------------------
 Fleet 3 - Bay Head Yacht Club - Barnagat Bay  
 Robert O'Brien, Fleet Captain
 David M Olney, Fleet Secretary


--------------------------------------------------------------------------------

 Fleet 26 - Little Egg Harbor - Little Egg Harbor Bay  
 Jody Robinson, Fleet Captain
 Franz K Schneider, Fleet Secretary


--------------------------------------------------------------------------------

 Fleet 34 - Metedeconk River Yacht Club - Metedeconk River  
 Mitchell Hnatt, Fleet Captain
 James G Carson, Fleet Secretary

Any ideas??
0
slegy
Asked:
slegy
  • 3
  • 3
1 Solution
 
Beverley PortlockCommented:
It seems to me that, stripping out some of the server side code, the HTML you are generating is like so

<table>
        <hr width=95% />
        <hr width=95% />
          <tr>
            <td width=450><%=(rsfleetInfo.Fields.Item("fleet").Value)%></td>
            <td width=220><%=(rsfleetInfo.Fields.Item("name").Value)%></td>
          </tr>
      </table>


Now - that just does not make sense. Those <Hr> tags should not be there, they should be more like


<table>
         <tr>
            <td colspan='2'>
                 <hr width=95% />
            </td>
         </tr>
          <tr>
            <td width=450><%=(rsfleetInfo.Fields.Item("fleet").Value)%></td>
            <td width=220><%=(rsfleetInfo.Fields.Item("name").Value)%></td>
          </tr>
      </table>




So it seems to me that your original code should look like this


    <div id="fleetInfo">
      <table>
        <tr>
        <td colspan='2'>
        <% iFleet = rsfleetInfo.Fields.Item("fleetNo").Value %>
        <hr width=95% />
        <% While ((Repeat2__numRows <> 0) AND (NOT rsfleetInfo.EOF))
          If rsfleetInfo.Fields.Item("fleetNo").Value <> iFleet then
                iFleet = rsfleetInfo.Fields.Item("fleetNo").Value%>
         <% End If%>
         </td>
         </tr>
          <tr>
            <td width=450><%=(rsfleetInfo.Fields.Item("fleet").Value)%></td>
            <td width=220><%=(rsfleetInfo.Fields.Item("name").Value)%></td>
          </tr>
          <%
        Repeat2__index=Repeat2__index+1
        Repeat2__numRows=Repeat2__numRows-1
        rsfleetInfo.MoveNext()
      Wend
      %>
      </table>
    </div>

0
 
slegyAuthor Commented:
The goal is to put a horizontal rule first, then put a horizontal rule before each change of fleet number. I'm trying to put a dividing line between each fleet grouping.
0
 
Beverley PortlockCommented:
slegy said "I'm trying to put a dividing line between each fleet grouping."

Fair enough - but the HR's must be enclosed in <td> tags within a table. The code you posted inserts the HR's "between" rows and that will not help. Also, I think you have a misunderstanding somewhere or you haven't explained it all - your examples show 3 lines of output per section but you only have two output statements that I can see.

Can you explain the format of your incoming data? What are you expecting it to look like as it comes in from the table/data stream?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
slegyAuthor Commented:
bportlock: are you saying that the only way I can get a dividing horizontal rule between each fleet grouping is to create a database field for it? The solution I listed was the one provided when I first posted this question. It appeared reasonable and I accepted it. Unfortunately, I did not fully test it before doing so. So I just want clarity. Are you saying that it is NOT possible to draw the horizontal line between fleet groupings by using the <hr> and that it has to come from the database?

TWO database fields are being displayed:
1. A fleet number, description, location (combined in one field)
2. The name and title of a fleet officer (combined in one field)
0
 
Beverley PortlockCommented:
slegy said"are you saying that the only way I can get a dividing horizontal rule between each fleet grouping is to create a database field for it?"

No I am not saying that. I am saying that if you want the HR in the table then it must be in a table cell. Your other option is to have individual tables for each grouping with HR between then. From looking at your code it seems that you are inserting the HR tag *between* the table's TR tags.


Have you tried the code below? What did it produce? I have put a "border" attribute on the HTML so that it is easier to see the table and where things are going and moved the spacing around to clarify the position of the HTML elements in relation to each other


    <div id="fleetInfo">
      <table border='1'>
      
        <tr>
           <td colspan='2'>
             <hr width=95% />
           </td>
        </tr>
        
        <% iFleet = rsfleetInfo.Fields.Item("fleetNo").Value %>
        <% While ((Repeat2__numRows <> 0) AND (NOT rsfleetInfo.EOF))
              If rsfleetInfo.Fields.Item("fleetNo").Value <> iFleet then
                 iFleet = rsfleetInfo.Fields.Item("fleetNo").Value%>
        <%    End If%>
        
        <tr>
           <td width=450><%=(rsfleetInfo.Fields.Item("fleet").Value)%></td>
           <td width=220><%=(rsfleetInfo.Fields.Item("name").Value)%></td>
        </tr>
        
        <%
              Repeat2__index=Repeat2__index+1
              Repeat2__numRows=Repeat2__numRows-1
              rsfleetInfo.MoveNext()
           Wend
        %>
        
      </table>
    </div>

Open in new window

0
 
slegyAuthor Commented:
Bless you - that is exactly what I was looking for. the "hr" code needed to be moved now with the "If" statment, and now it works perfectly. Thank you - it's good to get a better insight into how these things work!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now