The problem with displaying not one but two drop down lists in the row when the user selects "t-shirts" from the part number drop down list is that two drop down lists require two separate cells in the table as opposed to a single one with the description field. This gets a little complicated.
One way you could keep things relatively simple is by making a copy of the detail row and giving it another name (let's say we rename the detail row to "OtherDetail" and the new (copy) to "TShirtDetail"). In the new TShirtDetail row, you would replace the description field with a drop down list for the size. You would then select the description column and use the Table Tools to insert a column into the table. This will mess-up your table layout a little bit but it should be easy to clean-up. In the end, you want an extra cell only in the TShirtDetail row (this implies you'll need to merge some of the cells on the rows above and below the TShirtDetail row). Once you've got this layout, add the second drop down list to the TShirtDetail row for the color. Finally, select the txtPartNum drop down list in the TShirtDetail row and change its type to a text field set to read-only (using the Type property on the Object palette's Value tab) with a default value of "T-Shirt". You'll also need to remove "T-Shirt" from the part number arrays in the script which populates the txtPartNum drop down list in the OtherDetail row.
At this point, you'll have two rows: One specifically for t-shirts and the other for the remaining items (socks and pants). Now you'll need to add another button next to the existing "Add Item" button which adds an instance of the OtherDetail row. This new button will be the one which adds instances of the TShirtDetail row. Don't forget to modify the Click event scripts on these "add" buttons as well as each row's "X" button and all the total fields to use the new row names: "_detail" changes to "OtherDetail" and "TShirtDetail" depending on the row, the button and the total field. Finally, using the Object palette's Binding tab, I would the initial count of each row to 1 so that an instance of each one is initially visible.
Now you should have a functioning form in which you can add and remove "other" detail and "t-shirt" detail rows except for the fact that the instance of the TShirtDetail rows don't have unit prices anymore. Fixing this will also let us apply the "bulk discount" for quantities of t-shirts above 10.
By specifying script on the Calculate event of the numUnitPrice numeric field in the TShirtDetail row, you can specify what the price is depending on the quantity of t-shirts requested. The following script will set a reduced price is the quantity ordered in more than 10:
if (numQty.rawValue > 10) // if order more than 10, give discount
this.rawValue = 19.99;
else
this.rawValue = 24.99;
Because of the way form calculations work, all other total fields should properly reflect the change in price as the quantity and price change.
This will only work for a single row, though, so the script needs to be tweaked to count the total quantity of t-shirts across all instances of the TShirtDetail row. This can be done easily by retrieving a list of all TShirtDetail row instances using the "resolveNodes" function:
var nTotalShirtCount = 0;
var oTShirtDetailList = form1.purchaseOrder.details.
resolveNodes("TShirtDetail[*]");
for (var i = 0; i < oTShirtDetailList.length; i++)
{
var oTShirtDetailRow = oTShirtDetailList.item(i);
nTotalShirtCount += (oTShirtDetailRow.numQty.rawValue != null) ? oTShirtDetailRow.numQty.rawValue : 0;
}
if (nTotalShirtCount > 10) // if order more than 10, give discount
this.rawValue = 19.99;
else
this.rawValue = 24.99;
This script gets a list of all instances of the TShirtDetail row and, for each instance, accumulates the total number of t-shirts ordered and then applies the discount accordingly.
I've attached a modified version of the Purchase Order sample which implements these changes so you can see what I'm trying to explain here.
Stefan
Adobe Systems