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

Dialog issue - finding the selected item in a "popup" field

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Answered

Hi all,
 
This issue is driving me nuts...
I have created a dialog with several popup fields, all need to have the same values (a list of colors). So far so good. But when I try to find which value was actually selected, nothing works. I would appreciate any ideas as to why...
 
Here's the relevant parts of my code:
 

	initialize: function (dialog) {
		var listColors = {
				"": +1,
				"Yellow": -1,
				"Green": -2,
				"Red": -3,
				"Blue": -4,
				"Orange": -5,
				"Pink": -6,
				"Brown": -7,
				"Purple": -8
			}
		var dlgInit = {
			"col1": listColors,
			"col2": listColors,
		}
		dialog.load(dlgInit);
	}

 
 
	commit:function (dialog) {
		var rslts = dialog.store();
        var sel ="";
        for(var e in rslts["col1"]) {
			if (rslts["col1"][e] > 0) {
				app.alert(rslts["col1"][e])
			}
		}
	},

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

My Product Information:
Acrobat Pro 9.4, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
The problem is the empty entry. The dialog object does not properly assign a value to this entry when it's returned. On Acrobat 8 the blank entry returns a value of "undefined". What's interesting is that execution stops, but no exception is thrown. Execution just falls off in to a black hole. I haven't tried it on other versions. But using a single space fixes the problem.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Holy crap... This had me tearing out my hair...

As always, you save the day, Thom.

Thanks!

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com