Forums

ASP

This topic is locked

Nested repeat regions and form fields

Posted 26 Jan 2005 13:46:28
1
has voted
26 Jan 2005 13:46:28 Seb Adlington posted:
Hi,

I am building a trade shopping system where the product selection screen has nested repeat regions - each customer can add the price they would like to sell each item for. I have seperate table to store these prices and they are then displayed alongside the product lists when they are browsing. I'm trying to store all these details in a shopping cart before dumping it all in a database. Problem is that the Repeat3 repeat region puts all the values from the database into the form field even though this is buried in an if statement. i.e. if the user has ten private prices stored - all ten get put in the form field even though only one price gets displayed ?? The form fields are hiddengp and hiddensell

Cheers



<form name="form1" method="post" action="<%=UCII_editAction%>">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="2" ID="navlist">
<tr>
<td><div align="center">
<h4>Product Categories - Now Showing <span class="style6"><%=(RS_Products_total)%> - <%= Request.QueryString("value" %>
<% if (Request.QueryString("value"=="" ) { // Adv Conditional Region %>All
<% } // Request.QueryString("value"=="" All %>
</span></h4>
<% while ((Repeat2__numRows-- != 0) && (!RS_Categories.EOF)) { %>
<a href="products.asp?<%= Server.HTMLEncode(MM_keepNone) + ((MM_keepNone!=""?"&":"" + "value=" + RS_Categories.Fields.Item("value".Value %>">
<%=(RS_Categories.Fields.Item("category".Value)%></a>
<%
Repeat2__index++;
RS_Categories.MoveNext();
}
%>

</div></td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td><div align="center">To add or modify your selling price or GP for a product, please click the product description.</div></td>
</tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="2">
<tr bgcolor="#004205">
<td width="44%"><div align="center" class="style3">Description</div></td>
<td width="11%"><div align="center" class="style3">Size</div></td>
<td width="9%"><div align="center" class="style3">Packed<br>
by
</div></td>
<td width="11%"><div align="center" class="style3">Unit<br>
Cost
</div></td>
<td width="11%"><div align="center" class="style3">Unit<br>
Sell
</div></td>
<td width="8%"><div align="center" class="style3">G.P.</div></td>
<td width="6%"><div align="center"><span class="style3">Qty</span></div></td>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!RS_Products.EOF)) { %>

<tr>
<td><div align="left">
<%
RS_UserProducts.MoveFirst();
var xx=0;
%>
<% while ((Repeat3__numRows-- != 0) && (!RS_UserProducts.EOF)) { %>
<%if(RS_Products.Fields.Item("ID".Value == RS_UserProducts.Fields.Item("ProductID".Value){%>
<a href="edit_price.asp?<%= Server.HTMLEncode(MM_keepNone) + ((MM_keepNone!=""?"&":"" + "ID=" + RS_Products.Fields.Item("ID".Value %>"><%=(RS_Products.Fields.Item("Description".Value)%></a>
<%
xx=1;
}%>
<%
Repeat3__index++;
RS_UserProducts.MoveNext();
}
%>
<%if(xx==0){%>
<a href="add_price.asp?<%= Server.HTMLEncode(MM_keepNone) + ((MM_keepNone!=""?"&":"" + "ID=" + RS_Products.Fields.Item("ID".Value %>"><%=(RS_Products.Fields.Item("Description".Value)%></a>
<%}%>
</div></td>
<td><div align="center"><%=(RS_Products.Fields.Item("Size".Value)%></div></td>
<td><div align="center"><%= (RS_Products.Fields.Item("Per_Shelf".Value) %></div></td>
<td><div align="center">£<%=DoNumber(((RS_Products.Fields.Item("Nett_Cost".Value-(RS_Products.Fields.Item("Nett_Cost".Value)*userdiscount)), 2, -2, -2, -2)%></div></td>
<td><div align="center">
<%RS_UserProducts.MoveFirst();%>
<% while ((Repeat3__numRows-- != 0) && (!RS_UserProducts.EOF)) { %>
<%if(RS_Products.Fields.Item("ID".Value == RS_UserProducts.Fields.Item("ProductID".Value){ %>
£<%=DoNumber((RS_UserProducts.Fields.Item("Sell".Value), 2, -2, -2, -2)%><input name="hiddensell" type="hidden" id="hiddensell" value="<%=RS_UserProducts.Fields.Item("Sell".Value%>">
<%}%>
<%
Repeat3__index++;
RS_UserProducts.MoveNext();
}
%>


</div></td>
<td><div align="center">
<%RS_UserProducts.MoveFirst();%>
<% while ((Repeat3__numRows-- != 0) && (!RS_UserProducts.EOF)) { %>
<%if(RS_Products.Fields.Item("ID".Value == RS_UserProducts.Fields.Item("ProductID".Value){ %>
<%=(RS_UserProducts.Fields.Item("GP".Value)%><input name="hiddengp" type="hidden" id="hiddengp" value="<%=(RS_UserProducts.Fields.Item("GP".Value)%>">
%
<%
}
Repeat3__index++;
RS_UserProducts.MoveNext();
}
%>
</div></td>
<td><div align="center">
<input name="Qty" type="text" id="Qty" size="3">
<input type="hidden" name="UCII_recordId" value="<%= RS_Products.Fields.Item("ID".Value %>">
</div></td>
</tr>
<%
Repeat1__index++;
RS_Products.MoveNext();
}
%>
</table>
<div align="center">
<table width="350" border="0" cellspacing="3" cellpadding="1">
<tr>
<td><div align="center">
<input type="submit" name="Submit" value="Order Selected Products">
</div></td>
</tr>
</table>
<br>
<table width="95%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td bgcolor="#004205"><div align="center" class="style3"> Records <%=(RS_Products_first)%> to <%=(RS_Products_last)%> of <%=(RS_Products_total)%> </div></td>
</tr>
<tr>
<td><div align="center">
<table border="0" width="50%" align="center">
<tr>
<td width="23%" align="center">
<% if (MM_offset != 0) { %>
<a href="<%=MM_moveFirst%>"><img src="../graphics/First.gif" border=0></a>
<% } // end MM_offset != 0 %>
</td>
<td width="31%" align="center">
<% if (MM_offset != 0) { %>
<a href="<%=MM_movePrev%>"><img src="../graphics/Previous.gif" border=0></a>
<% } // end MM_offset != 0 %>
</td>
<td width="23%" align="center">
<% if (!MM_atTotal) { %>
<a href="<%=MM_moveNext%>"><img src="../graphics/Next.gif" border=0></a>
<% } // end !MM_atTotal %>
</td>
<td width="23%" align="center">
<% if (!MM_atTotal) { %>
<a href="<%=MM_moveLast%>"><img src="../graphics/Last.gif" border=0></a>
<% } // end !MM_atTotal %>
</td>
</tr>
</table>
</div></td>
</tr>
</table>
</div>
</form>

Replies

Replied 26 Jan 2005 14:11:07
26 Jan 2005 14:11:07 Michael Behan replied:
Instead of using an if statement after the start of the repeat region include the criteria you want in the while statement.
<pre id=code><font face=courier size=2 id=code>&lt;% while ((Repeat3__numRows-- != 0) && (!RS_UserProducts.EOF)) { %&gt;
&lt;%if(RS_Products.Fields.Item("ID".Value == RS_UserProducts.Fields.Item("ProductID".Value){ %&gt;</font id=code></pre id=code>

would become

<pre id=code><font face=courier size=2 id=code>&lt;% while ((Repeat3__numRows-- != 0) && (!RS_UserProducts.EOF) && (RS_Products.Fields.Item("ID".Value == RS_UserProducts.Fields.Item("ProductID".Value)) { %&gt;</font id=code></pre id=code>

I've had similar problems with nested repeat regions that have been sorted by doing this. <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code> <pre id=code><font face=courier size=2 id=code> </font id=code></pre id=code>
Replied 26 Jan 2005 15:15:34
26 Jan 2005 15:15:34 Seb Adlington replied:
Hi Michael,

Thanks for that - looks like it should do the job but now I'm not getting any
display at all - The rest of the page works fine but the data in the while loops
is not being displayed. Looks like the Conditions are not being tripped but the
data definately matches. I've tried a few variations with the while statement but
same result?? Any ideas?

Cheers

Seb
Replied 26 Jan 2005 15:28:51
26 Jan 2005 15:28:51 Seb Adlington replied:
Just got it partially working.
If the UserProducts recordset has the right record in forst place then it will display
the data and work properly, but not otherwise. Thing is, If maybe 10 products are
displayed, maybe only three of them will have an associated price...

Reply to this topic