These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

popup menu button apply to field

Duniagdra
Registered: Sep 24 2008
Posts: 140
Answered

I found this sample code on this site:

var aFruits = ["Fruits","Apples",["Oranges","navel","valencia"]];
var aVeggies = ["Vegetables","Beans","Corn"];
 
// Create an array to hold the top level menu entries
var aTopItems = [aFruits, aVeggies];
 
// Place Additional entry at end of the Top Level Item Array
var aBerries = ["Berries","Huckle","Goose"];
 
aTopItems.push(aBerries);
var cRtn = app.popUpMenu.apply(app, aTopItems);
 
if(cRtn != null)
   this.getField("Myfld").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.

[b]The result would be oranges navel 12 fruit 3lbs.[/b]

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
var aFruits = ["Fruits","Apples",["Oranges","navel","valencia"]];
var aVeggies = ["Vegetables","Beans","Corn"];

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

// Place Additional entry at end of the Top Level Item Array
var aBerries = ["Berries","Huckle","Goose"];

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

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

if(cRtn != null)
this.getField("Myfld").value = cRtn;

If you use this code on a button field, then the "event.target" is the button field or the field trigging the action and the "event.target.name" is the name of the field.

George Kaiser

Duniagdra
Registered: Sep 24 2008
Posts: 140
gkaiseril wrote:
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];

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

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

if(cRtn != null)
this.getField("Myfld").value = cRtn;

If you use this code on a button field, then the "event.target" is the button field or the field trigging the action and the "event.target.name" is the name of the field.
Thanks gkaiseril for helping me in this. I've tried your example and this is what I've done:
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 entriesvar 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;

Now when I click the button and follow the menu and select, I get an error and debugger opens with:

Debugger wrote:
"You selected: Macintoshthis.getField("text4") has no properties
15:Field:Mouse Down"
I've created the following but don't know how to execute it:
var oProduct = {Macintosh: [3,"Fruit","1lbs."],Red_Delishious: [7,"Sweet","1/2lbs."],};

And I have it at the document level.

Do you have any suggestions?

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

Duniagdra
Registered: Sep 24 2008
Posts: 140
gkaiseril wrote:
If you use this code on a button field, then the "event.target" is the button field or the field trigging the action and the "event.target.name" is the name of the field.
I'm sorry... I just read your post again and just to be sure... this above response was direct at my post below?
Duniagdra wrote:
[b]I was planning to use:
var cRowName = event.target.name.split(".").shift();
[/b]

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You might want to try push and pop to move the elements into the stack before using shift.

George Kaiser

Duniagdra
Registered: Sep 24 2008
Posts: 140
gkaiseril wrote:
You might want to try push and pop to move the elements into the stack before using shift.
While I truly do appreciate your help, I have to say, that just went right over my head. I don't have time right now as I'm expected to be somewhere soon, but I'll look up push and pop tomorrow. Is there a reference book you might recommend that has a good base of definitions?

I was actually going to try and hack my way through this method:
function SetPartEntries(){if(event.willCommit){var cRowName = event.target.name.split(".").shift(); var lst = oAssemblyParts[event.value]; if( (lst != null) && (lst.length > 0) )this.getField(cRowName + ".PartSelect").setItems(lst);else{this.getField(cRowName + ".PartSelect").clearItems();}this.getField(cRowName + ".Price").value = 0;}}

I found that in an example on this site, "ListProgramming_Part1.pdf".
But I'm game for what ever you suggest as to be the best way to approach this.

Thanks again for your help gkaiseril,
Jim

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

Duniagdra
Registered: Sep 24 2008
Posts: 140
I've tried looking up this push and pop, but I keep getting everything under the sun no matter how I arrange the search criteria. Can you explain how they work or what you were meaning?

Also, having multiple rows that would end up having different items I'm thinking I'll need a button for each row, just to keep it not so complicated I think.

Any suggestions?

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

Duniagdra
Registered: Sep 24 2008
Posts: 140
gkaiseril wrote:
You might want to try push and pop to move the elements into the stack before using shift.
How do I use this push and pop? I'm not having any luck on my own. I don't know where I'm supposed to use them.

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

Duniagdra
Registered: Sep 24 2008
Posts: 140
I'm still trying to figure my own way through this issue, but I'm not having any luck.

Here is my code:

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 entriesvar aTopItems = [aFruits, aVeggies]; var cRtn = app.popUpMenu.apply(app,aTopItems); console.show();console.clear();console.println("You selected: " + cRtn); if(cRtn != null)this.getField("text4").value = cRtn;

I'm trying to get this button menu to put the selected fruit or vegetable into a related field. I've tried a number of ways to get this to happen and I'm still at this stage. If a user selects "Green" or "Kidney", how do I get this value entered into the field named "test4"?

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

Duniagdra
Registered: Sep 24 2008
Posts: 140
Duniagdra wrote:
I'm still trying to figure my own way through this issue, but I'm not having any luck.Here is my code:

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 entriesvar aTopItems = [aFruits, aVeggies]; var cRtn = app.popUpMenu.apply(app,aTopItems); console.show();console.clear();console.println("You selected: " + cRtn); if(cRtn != null)this.getField("text4").value = cRtn;

I'm trying to get this button menu to put the selected fruit or vegetable into a related field. I've tried a number of ways to get this to happen and I'm still at this stage. If a user selects "Green" or "Kidney", how do I get this value entered into the field named "test4"?
I keep getting this message from debugger in console:

You selected: Macintosh

this.getField("text4") has no properties
15:Field:Mouse Down

So I did the following:
var oProduct = {Macintosh: [3,"Fruit","1lbs."],Red_Delishious: [7,"Sweet","1/2lbs."],};  function SetSelectionValue(){if(!event.willCommit){var cRowName = event.target.name.split(".").shift();  this.getField(cRowName + ".text4").value = oProduct;}}

and put SetSelectionValue() in the custom keystroke format properties of row1.text4, but I still get same error.

To note: I changed the field name to Row1.text4

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Acrobat can not find that field. Make sure the name is an exact match, caps and spelling.

George Kaiser

Duniagdra
Registered: Sep 24 2008
Posts: 140
gkaiseril wrote:
Acrobat can not find that field. Make sure the name is an exact match, caps and spelling.
Okay, it's always the obvious that is over looked. I had a lower case "t" instead of and upper case "T". Now I can move on to my next hurdle of having the fields of the same row react to the input. I created an array of values, but I'm having trouble getting the fields to pick up on the proper values. I'll start a new thread for that.

Thanks again for your help gkaiseril.

Thanks in advance for any help provided,
Jim
The All Time Professional Amateur Hack