Incremental Looping (appending an x to a string in a loop)

Author Message
nbardach

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 1/1/2009
  • Status: offline
Incremental Looping (appending an x to a string in a loop) Thursday, January 01, 2009 6:30 PM (permalink)
0
Hope this finds everyone well. Happy New Year!
 
I'm trying to build a Loop for a set of dropdown menus I'm inserting into a form.
 
Basically, the client has to be able to select 1 to 20 donors with the dropdown options pulled from the DB. When the client is editing a donation record, she needs to be able to view the correct donors for a specific donation record selected in the dropdowns. This means matching the Donor ID's in the Donations Table with the Member ID's in the Members table, and then pulling the member's name to display in the dropdown.
 
Unless I can find a way to loop, I've got to have 20 of these in my code :(
 
Below is what the non-incremental, non-loop dropdown looks like:
 
   <div id="donor_1" style="display:inline">
 
    <select name="Donor_ID_1">
    <option value="">-- Select the Donor --</option>
    <% DO UNTIL MembersInfo.EOF %>
 <% strMembersID1 = MembersInfo.Fields("ID") %>
 <% intComparison1 = strComp(strMembersID1, strRecord_ID_1) %>
    <option <% IF intComparison1 = 0 THEN %>selected<% END IF %> value="<%=MembersInfo.Fields("ID")%>"><%=MembersInfo.Fields("L_Name")%>, <%=MembersInfo.Fields("F_Name")%>&nbsp;<% IF MembersInfo.Fields("M_Init") <> "" THEN%><%=MembersInfo.Fields("M_Init")%><% END IF %> (User ID: <%=MembersInfo.Fields("ID")%>)</option>
    <% MembersInfo.MOVENEXT %>
    <% LOOP %>
    <% MembersInfo.MOVEFIRST %>
    </select> &nbsp;<input type="button" value="+" name="add_donor_1" onClick="toggleBox('donor_2',1);" title="Add an Additional Donor"><br>
 
    </div>

 
Here's my attempt at a loop...but it's not working: 

 <%
 x = 1
 DO WHILE x < 21
 %>
 <div id="donor_<%=x%>" style="display:inline">
 
    <select name="Donor_ID_<%=x%>">
    <option value="">-- Select the Donor --</option>
    <% DO UNTIL MembersInfo.EOF %>
 <% strMembersID+"&x&" = MembersInfo.Fields("ID") %>
 <% intComparison+x = strComp(strMembersID+x, strRecord_ID_+x) %>
    <option <% IF intComparison+x = 0 THEN %>selected<% END IF %> value="<%=MembersInfo.Fields("ID")%>"><%=MembersInfo.Fields("L_Name")%>, <%=MembersInfo.Fields("F_Name")%>&nbsp;<% IF MembersInfo.Fields("M_Init") <> "" THEN%><%=MembersInfo.Fields("M_Init")%><% END IF %> (User ID: <%=MembersInfo.Fields("ID")%>)</option>
    <% MembersInfo.MOVENEXT %>
    <% LOOP %>
    <% MembersInfo.MOVEFIRST %>
    </select> &nbsp;<input type="button" value="+" name="add_donor_<%=x%>" onClick="toggleBox('donor_<%=x+1%>',1);" title="Add an Additional Donor"><br>
 
    </div>
    <% x = x+1 %>
 <% LOOP %>

 
Any and all help would be greatly appreciated. I feel like I'm just blowing the syntax on appending the incremental integer to the other strings.
 
Many thanks in advance! Noah

 
#1
    webber123456

    • Total Posts : 58
    • Scores: 0
    • Reward points : 0
    • Joined: 9/20/2007
    • Status: offline
    RE: Incremental Looping (appending an x to a string in a loop) Sunday, January 04, 2009 4:45 AM (permalink)
    0
    use arrays:

    <% dim strMembersID(20) %>
    .....

    <% strMembersID(x) = MembersInfo.Fields("ID") %>

    ....
    <message edited by webber123456 on Sunday, January 04, 2009 4:47 AM>
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9