Print Page | Close Window

Form/Database Update only applying to first record

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=31612
Printed Date: 05 June 2020 at 3:46pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: Form/Database Update only applying to first record
Posted By: lee2121
Subject: Form/Database Update only applying to first record
Date Posted: 22 May 2019 at 4:37pm
I'm in the middle of developing a classic asp website and we have a cart function which displays whats currently in the users cart, this workd well it displays however many products they have in there cart using a repeat region.

We have an option where the user can update the qty per item, this only works on the first item in the recordset and no matter what button you press i.e whichever line the qty is updated on the first product only.

See code below, any suggestion would be appreciated:

<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<form action="<%=MM_editAction%>" METHOD="POST" name="form1">
  <tr>
    <td class="image">
      <a href="shop.asp?sku=<%=Recordset1.Fields("sku")%>&sessionx=<%=Recordset1.Fields("sessionx")%>"> <img class="img-fluid" src="<%=(Recordset1.Fields.Item("image").Value)%>" alt=""/></a>
    </td>
    <td class="description">
       <a href="shop.asp?sku=<%=Recordset1.Fields("sku")%>&sessionx=<%=Recordset1.Fields("sessionx")%>"><%=(Recordset1.Fields.Item("name").Value)%></a>
    </td>
    <td class="price">£<%=(Recordset1.Fields.Item("totalprice").Value)%></td>
    <td class="td-quentety">
      <input type="number" value="<%=(Recordset1.Fields.Item("qty").Value)%>" name="qty">
     
    </td>
    <td class=""><a class="button mt-10" href="#" onclick="document.forms['form1'].submit(); return false;">Update</a>
      <input type="hidden" name="MM_update" value="form1">
      <input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("idx").Value %>">
    </form>
    </td>
    <form ACTION="<%=MM_editAction%>" METHOD="POST" name="form2">
    <td class=""><a class="button mt-10" href="#" onclick="document.forms['form2'].submit(); return false;">Remove</a></td>
  </tr>
  <input type="hidden" name="MM_delete" value="form2">
  <input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("idx").Value %>">
    </form>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net