Date:  11/27/2007 05:49:01 PM Msg ID:  003602
From:  FoxWeb Support Thread:  003601
Subject:  Re: Updating entry from many input tags
Your code creates multiple text boxes with the exact same name, which makes it impossible to identify which is which.  What you need to do is vary the name in a way that identifies the record.  I usually add the unique id of the record that each field refers to.  for example, if the unique id in your cart table is ItemId, you could re-write your code as follows:

.
.
.
<%for i = 1 to lnRecs%> (found 3 recs for example)
<%GO i%>

  <INPUT TYPE=text NAME="cquant_<%=cCart.ItemId%>" SIZE=3 MAXLENGTH=3 VALUE="<%=(m.cquant)%>">
<%endif%>
.
.
.


This would create fields with names like cquant_1529, cquant_1632, etc.  The receiving code could then use the Request.FormArray method to retrieve all form fields, look through the array for fields, whose names start with the text "cquant_" and identify the corresponding records by extracting the text after the "_" character.

By the way, there may be a reason why you are doing this, but it seems to me that a SCAN loop would be cleaner and faster than a FOR loop in conjunction with the GO statement:

.
.
.
<%scan%>

  <INPUT TYPE=text NAME="cquant_<%=cCart.ItemId%>" SIZE=3 MAXLENGTH=3 VALUE="<%=(m.cquant)%>">
<%endscan%>
.
.
.


Regards,
FoxWeb Support Team
support@foxweb.com email
Sent by Joe Goldsmiith on 11/27/2007 05:02:24 PM:
Hi all. I have a working shopping cart that I just found out that it does not work well with Safari. I found the offending code and concluded that, based on the totality of the script, needs to be rewritten.

Currently, the script reads in all the chosen products and the quantity desired. The quantity is just written to the screen and an up arrow and a down arrow allows the user to change the amount. Safari hates this.

I decided to rebuild a script with HTML input boxes but quickly realized that when the update button is pressed that I do not know (cannot tell) which product to update quantity. In the bit picture:

<%
if fequest.formcount("btnchoice") > 0
  **Find which record needs a quantity change
endif
%>
<%
use cart
select * from cart where cartID == custID into cursor cCart
select cCart
lnRecs = reccount()
%>
<FORM NAME="cart" METHOD="post" ACTION="addcart.fwx">
<%for i = 1 to lnRecs%> (found 3 recs for example)
<%GO i%>

  <INPUT TYPE=text NAME="cquant" SIZE=3 MAXLENGTH=3 VALUE="<%=(m.cquant)%>">
<%endif%>
<INPUT TYPE=SUBMIT NAME=btnchoice VALUE="Update">
</form>


So, if the customer updates the second of three quantities then how do I know which quantity to update when the Update button is pressed?

Thanks for your help.