PDA

View Full Version : Using popUpMeny to apply value to row


Jim Colella
10-11-2008, 08:57 PM
I found this sample code in the internet:

var aFruits = ["Fruits",["Apples","Macintosh","Red_Delicious","Green"],["Oranges","navel","valencia"],["Berries","Huckle","Goose"]];
var aVeggies = ["Vegetables",["Beans","Kidney","Black_eyed"],["Corn","Sweet","Stock"]];

// Create an array to hold the top level menu entries
var aTopItems = [aFruits, aVeggies, aArmor];

var cRtn = app.popUpMenu.apply(app,aTopItems);

console.show();
console.clear();
console.println("You selected: " + cRtn);

if(cRtn != null)
this.getField("text4").value = cRtn;
How do I get this to apply to a field?
I'm creating a form that will have multiple rows reactive to the selection of one field/button. I was planning to use the app.popUpMenu from a button, but all examples I'm finding so far show it triggering hyperlinks or documents. Can someone help me in getting this to populate a field? My fields are defined as follows:

Row1.Item Row1.Bonus Row1.Dmg Row1.Rng
Row2.
Row3.

I was planning to use:
var cRowName = event.target.name.split(".").shift();
But this I will try to hash out on my own first. I'm failing in hashing out this popup menu.

The result would be oranges navel 12 fruit 3lbs.

When I try the code out I get the following:
"You selected: Macintosh

this.getField("text4") has no properties
15:Field:Mouse Down"
I tried creating the following array, but don't know how to execute it so the menu selection will apply these values to the row in question:

var oProduct = {
Macintosh: [3,"Fruit","1lbs."],
Red_Delishious: [7,"Sweet","1/2lbs."],
};

I have this at the document level while the top code is at the button level.