Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    124

    Unanswered: looping question

    I currently have a loop to dynamically create table rows using the
    following:
    <%
    Dim x
    Dim MaxRows
    MaxRows = 25
    MaxRows = MaxRows - 1
    For x = 0 to MaxRows
    %>
    <tr>
    <td>...</td>...
    etc...
    </tr>
    <%
    Next
    %>

    Instead of having MaxRows set at 25, I'd like to have a small graphic that a
    user can click on that will trigger the loop to create another row. Is there a way to do this? If so, can anyone
    point me in the right direction on how to accomplish this?

    Thanks in advance for any help.
    -Dman100-

  2. #2
    Join Date
    Oct 2003
    Posts
    357

    Thumbs up

    Hi, try this logic
    Use session variable say session("Range")
    initialise session("Range") to 0
    in the graphic botton onclick event try this.
    Increase the session variables by 1 and call this fuction having the code like the following
    Code:
    <%
    Dim x
    For x = session("Range") to Session("Range")
    %>
    <tr>
    <td>...</td>...
    etc...
    </tr>
    <%
    Next
    %>
    Madhivanan

  3. #3
    Join Date
    Jan 2004
    Posts
    124
    Thanks for replying to my post. I created the following subprocedure:

    <%
    Dim Rows
    Rows = 1
    Sub tblRange
    Rows = Rows + 1
    End Sub
    %>

    then for the table loop:
    <%
    Dim x
    For x = Rows to Rows
    %>
    <tr>
    <td>....</td>
    etc...
    </tr>
    <%
    Next
    %>

    I have a button where I call the procedure like so:

    <input type="button" name="Button" value="New Transaction" onClick="<%call tblRange%>">

    One row is created, but when I click on the button to increment and add another row, nothing happens. Where did I go wrong in the logic or my code?

    Thanks again for your help.
    -Dman100-

  4. #4
    Join Date
    Oct 2003
    Posts
    357
    Hi Instead of using a local variable Rows use session variable so that it will not be reset everytime the procedure is called.
    Code:
    <%
    Dim Rows
    Rows = 1
    Sub tblRange
    Session("Rows") = Session("Rows") + 1
    End Sub
    %>
    
    then for the table loop:
    <% 
    Dim x 
    For x = Session("Rows") to Session("Rows")
    %>
    <tr> 
    <td>....</td>
    etc...
    </tr>
    <%
    Next
    %>
    Madhivanan

Posting Permissions

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