SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Table populated by dynamic checkboxes

    Hello everyone!

    I'm hoping some kind soul will be able to help me here as I'm getting increasingly puzzled!

    I'm wanting to produce a table of dynamic content:

    'Sizes' as the columns

    'Fit' as the rows

    Both Sizes and the columns are variables so could produce any quantity of results.

    But as an example, it could be something like this:

    <empty cell> Col1 Col2 Col3 Col4
    Row1
    Row2
    Row3
    Row4

    The value of one of the checkboxes would return, for example 'Col2/Row3'.

    I have built the dynamic table with columns and rows, but I'm struggling to populate the remaining cells in the way I want.

    Work so far here: http://www.uniformsforwork.com/matrix2.asp

    Ultimately I want the resulting 'empty' cells to have a checkbox in them that has a value relating to the row/column it is in.

    Has anybody used this in the past they would like to share with me?! Many thanks!

    And Merry Christmas!

  2. #2
    SitePoint Zealot gidday's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bertcast

    You need to provide us with some of code so we can get a better idea of how you are doing this.
    Joe
    "All that is necessary for the triumph of evil
    is that good men do nothing."

  3. #3
    SitePoint Member
    Join Date
    Jan 2009
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!
    After all the database calls, the page layout is shown like this. This is a combination of code I wound on the web and code Dreamweaver produces. The databases consist of: a full SIZE table, the full FIT table, a SQL COUNT for both tables (to determine how many rows/columns there will be) and a repeat of both the FIT and SIZE tables to use in the empty cells.

    Code ASP:
    <%
        Dim iNumRows
        Dim iNumCols
     
        'set number of rows and columns
        iNumRows=(RS_FitCount.Fields.Item("fittotal").Value)
        iNumCols=(RS_SizeCount.Fields.Item("sizetotal").Value)
    %>
     
      <table border="1" cellpadding="3" cellspacing="3" align="center" width="100%">
     
        <tr>
          <td>&nbsp;</td>
          <% 
    While ((Repeat1__numRows <> 0) AND (NOT RS_Sizes.EOF)) 
    %>
            <td><%=(RS_Sizes.Fields.Item("size_name").Value)%></td>
            <% 
      Repeat1__index=Repeat1__index+1
      Repeat1__numRows=Repeat1__numRows-1
      RS_Sizes.MoveNext()
    Wend
    %>
        </tr>
     
        <%
            Dim iRows
            Dim iCols
            For iRows=1 To iNumRows Step 1
        %>
     
     
        <% 
    While ((Repeat2__numRows <> 0) AND (NOT RS_Fit.EOF)) 
    %><tr>
          <td><%=(RS_Fit.Fields.Item("fit_name").Value)%></td>
     
            <%
                        For iCols=1 To iNumCols Step 1
                    %>
     
     
     <% 
    While ((Repeat3__numRows <> 0) AND (NOT RS_SizeCheckBox.EOF)) 
    %>
            <td><%=(RS_SizeCheckBox.Fields.Item("size_name").Value)%>/<%=(RS_FitCheckbox.Fields.Item("fit_name").Value)%></td>
        <% 
      Repeat3__index=Repeat3__index+1
      Repeat3__numRows=Repeat3__numRows-1
      RS_SizeCheckBox.MoveNext()
    Wend
    %>	
     
     
     
    		<%
                        Next
                    %>
          </tr>  <% 
      Repeat2__index=Repeat2__index+1
      Repeat2__numRows=Repeat2__numRows-1
      RS_Fit.MoveNext()
    Wend
    %>
          <%
            Next
        %>
      </table>

    Thank you for taking the time to look!
    Last edited by Mittineague; Dec 24, 2010 at 11:41. Reason: reformatting bbcode tags

  4. #4
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To populate a dynamic check box use this code

    <%
    while not rs.EOF
    dim totval,k
    totval=int(rs.RecordCount)
    %>
    <input type="checkbox" name="cb&<%= k %>" value="<%=rs("Id") %>">
    <%
    k=k+1
    rs.MoveNext
    wend
    rs.close
    Conn.Close
    %>

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No. Don't put a Dim statement inside a loop.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •