Date:  09/16/2009 02:10:00 PM Msg ID:  004033
From:  FoxWeb Support Thread:  004031
Subject:  Re: Invoice coding help needed

In order to identify the product that individual Quantity and Total fields refer to, you will need to append some identifying information to the field names.

Here's an example, with the changes from your original code highlighted:


<TD> && Quantity already converted from integer to text
    <INPUT TYPE=TEXT NAME="quantity_<%=RECNO()%>" SIZE=3 MAXLENGTH=3 VALUE="<%=(quantity)%>">
<TD> && Total already converted from numeric to text with str(total,8,2)
    <INPUT TYPE=TEXT NAME="Total_<%=RECNO()%>" SIZE=10 MAXLENGTH=10 VALUE="<%=(Total)%>">


The above code uses the record number, but a more appropriate value would be the key of that particular detail record.

The code that processes the form results will have to scan all fields whose names start with "quantity_" and "total_". The part of the field name after the underscore will help you identify the detail item that each field refers to. You can scan through fields by retrieving the whole list in an array with the FormArray method.

FoxWeb Support Team email
Sent by Joe Goldsmiith on 09/16/2009 11:15:09 AM:
 My app handles the creation of an invoice that sometimes needs to be edited. My table set up is Order table links to Detail table where the Detail table holds the itema ordered with other rows showing discounts, tax, etc such as
 Product Price
 Quantity  Total
 Product 1
 100.00  1  100.00
 Product 2  200.0  2  400.00
 Discounts  10.00  1  10.00
 Credits  0.00  1  0.00
 Tax  0.00  1  0.00
 Total      490.00
When the Form is created I open Orders and present necessary information to identify that the right order is being edited. I then open the Details table using:
SELECT * FROM data/sales!Details WHERE DORDER = M.OrderID INTO CURSOR cDetails
 and then Scan through the cursor to present the table above. Within the Scan to allow editing I populate the table with the following code segment:

        <TD align="center">Product</TD>
        <TD align="center">Price</TD>
        <TD align="center">Quantity</TD>
        <TD align="center">Total</TD>
    <%SELECT cDetails%>
        <TD> && Quantity already converted from integer to text
            <INPUT TYPE=TEXT NAME="quantity" SIZE=3 MAXLENGTH=3 VALUE="<%=(quantity)%>">
        <TD> && Total already converted from numeric to text with str(total,8,2)

           <INPUT TYPE=TEXT NAME="Total" SIZE=10 MAXLENGTH=10 VALUE="<%=(Total)%>">


        <TD VALIGN="TOP" ALIGN="center" colspan="4" bordercolor="white">
            <INPUT class=formButton TYPE=SUBMIT NAME=btnchoice VALUE="Update Dealer's Order Details">


As shown in the code above and the table above, I want the user to be able to change the quantity and total for one or both products. When the INPUT button is pressed the page is reloaded and a request.formcount() and request.form() captures the values of the edited and UPDATEs the right row/fields in the Details table.
Also, each product is designated with the general ledger ID field of "4010" so when the form is sent and captured with the request.formcount() I can use COUNT FOR GL="4010" to lnGL to learn that the order has two products allowing me to loop through products n number of times to get each product's individual quantity and total change.
The problem is I cannot figure out how isolate and capture each Product row individually with its Quantity and Total changes since the NAME="Total" is the same name for each product row in the INPUT tag. Since the order for each product is the same be it in the table and the form -  I know that Product 1 and Product 2 are the first two rows. I have tried changing the NAME= parameter with a known unique name such as:

loop = 0

loop = loop +1

NAME = STR(loop)



FOR I = 1 to lnGL

  lnQuantity = request.form('I') && and other various attempts at the correct syntax

  **Get quantity and update correct product


But the request.form() keeps giving me an empty quantity. Anyone have an idea as to how to capture these changes? I would certainly appreciate any help