If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > looping question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-04, 22:31
-Dman100- -Dman100- is offline
Registered User
 
Join Date: Jan 2004
Posts: 124
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-
Reply With Quote
  #2 (permalink)  
Old 11-24-04, 05:56
Madhivanan Madhivanan is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 11-24-04, 10:53
-Dman100- -Dman100- is offline
Registered User
 
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-
Reply With Quote
  #4 (permalink)  
Old 11-25-04, 00:15
Madhivanan Madhivanan is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On