Populating Prices from Dropdown Box
Hi,
I have been trying to write a script that automatically populates a price in another field once an item in a dropdown box is selected. From looking at the tutorials, I have a good portion completed but I am running into the issue where every "cost" field is populated and I am not sure how to create a 1:1 selection with each row.
Example: desc1 populates for cost1
desc2 populates for cost2
Code:
var cateringData = { "Large Cheese Board":{ cost: "165"},
"Regular Cheese Board":{cost: "98"}};
function setFieldValues(cCateringName)
{
this.getField("cost1").value = cateringData [cCateringName].cost;
this.getField("cost2").value = cateringData [cCateringName].cost;
this.getField("cost3").value = cateringData [cCateringName].cost;
this.getField("cost4").value = cateringData [cCateringName].cost;
this.getField("cost5").value = cateringData [cCateringName].cost;
this.getField("cost6").value = cateringData [cCateringName].cost;
this.getField("cost7").value = cateringData [cCateringName].cost;
this.getField("cost8").value = cateringData [cCateringName].cost;
this.getField("cost9").value = cateringData [cCateringName].cost;
this.getField("cost10").value = cateringData [cCateringName].cost; }
Then this code is in the dropdown box field (desc1),
if( event.willCommit ) {
if(event.value == "") this.resetForm(["cost1"]); else setFieldValues(event.value); }

Any help is much appreciated!
Thanks!
