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

Two problems with Dropdown lists and generally being new to livecycle

louiscar
Registered: May 7 2010
Posts: 7
Answered

I am designing a form which basically allows a number of choices for photoframes / pictures some of which are mutually exclusive. This is my first attempt at using livecycle so I'm a little in the deep end.

Problem 1:

I have set options in an xml file to provide the choices but have one annoying problem in that one of the dropdowns will force the description when a duplicate value is present eg.

eg. In my xml file I have:

[code][Frames>
[option type="Wood sm " price="13.5"/>
[option type="Wood med " price="18."/>
[option type="Wood lg " price="25"/>
[option type="Nielsen sm " price="18"/>
[option type="Nielsen med" price="25"/>
[option type="Nielsen lg " price="32"/>
[/Frames>

Note: opening square bracket is intentional since I am told I cannot post html so had to change them. In the xml of course they are all left chevrons[/code]
What happens here is that if "nielsen sm" or "Nielsen lg " is chosen the field will ber forced to "Wood Med" or "wood lg".

The field is bound to "frames" but it appears that "type" is being overuled by the value and since it finds a value of 18 in "wood med" it chooses that even though "Nielsen sm" was chosen. This appears to be a bug as it's nonsensical to me.
I can stop this happening by simply making the text slightly different eg. putting "18." but that seems unecessarily clumsy to me.

Dynamic properties for this field are:

Items : Frames.option[*]
Item text : Frames.option.type
Item value: Frames.option.price

Is this normal and should I be doing this differently?

Problem 2:

I have two columns that relate to size and mount type. eg. 5 sizes and 2 mounts. The first two sizes should allow only two of the 4 possible mounts and the other three would allow the other two. Basically I am giving the choice of two types of small or large mounts and want to limit the data shown in the dropdown list.

XML:

	[PicSize>	
			[option dim="7x5" price="7.5" mount="smount"/>
	   	        [option dim="9x6" price="12.5" mount="smount"/>
	   	        [option dim="8x10" price="15" mount="smount"/>
	   	        [option dim="A4" price="18" mount="lmount"/>
	   	        [option dim="A3" price="25" mount="lmount"/>
	   	[/PicSize>
		[Mounts>
			[option des="sm       " price="2.25"/>
			[option des="sm backed" price="3.0"/>
			[option des="lg       " price="3.5"/>		
			[option des="lg backed" price="4.5"/>
	[/Mounts>
 
Note: opening square bracket is intentional since I am told I cannot post html so had to change them. In the xml of course they are all left chevrons

So if 7x5 or 9x6 are chosen the mount choice would appear as "sm" and "sm backed".

This I'm sure isn't a problem I simply don't quite know how to do it so if someone could show me the way to handle this situation I'd be grateful.

L

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
It is a not so well documented rule that the bound values for a list must be unique. And it is a common mistake to place data associated with an item as the bound value. But this is a bad practice, as you've already found out. The solution to matching data to a list item is to use a mapping object, i.e. create a JavaScript object that maps item names to the values you want associated with the item. Then use this object to transfer data into a field.

The same solution works for using a one drop list to modify the contents of another.

Read this article:
http://www.acrobatusers.com/tutorials/2007/js_list_combo_livecycle/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

louiscar
Registered: May 7 2010
Posts: 7
thomp wrote:
It is a not so well documented rule that the bound values for a list must be unique. And it is a common mistake to place data associated with an item as the bound value. But this is a bad practice, ......
Thanks for the reply Thom. I was perhaps hoping there was a bit more in the way of a simple set of internal functions to get some of the simple stuff done without going into javascript.

However, you've certainly saved me a lot of time I might have wasted looking for a way to modify the way the list box was handled.

I guess I'm going to have to learn a bit more to get this sorted. I did come across your article (first link), but I wasn't sure where to put the code and how it gets triggered. Yes I'm that new to Livecycle so I'd only just found out how to connect an xml file to a combo box.

I also wasn't aware that what I was doing was bad practice, I thought it useful that I could make a form that could have it's reliant data changeable by a simple alteration of the xml file associated with it so once the form was done it would suffice even if items or prices changed. The idea of not hard coding the data into the form seemed like a plus to me.

I'll go through your links more thoroughly now.

Thank you
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well, yes, it would be nice if it was all automatic. You can automatically setup the list entries and export values using Dynamic Binding. But unfortunately this only gets you part of the way there.

Since you are working slightly outside the box you will need to do some scripting. To get any useful features Scripting is almost always necessary. But you can still use the XML file to setup your data. The trick is to find a way to get those unique entries and still get the data you need.

If you needed to associate a large and complex set of data with each entry you'd need some kind if full blown data mapping scheme. In the past I've loaded data into a hidden list or text field object and then parsed the data out for use on the form.

But since all you need is one simple piece of data there is an easy method. Append something to the price data to make it unique. For example, place an index number in front of each like this

1:12.5, 2:3.0, 3:2.25, etc.

The #: can be stripped out using simple string functions.

var price = MyList.rawValue.split(":").pop();

So, you can still use the price as the export data.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

louiscar
Registered: May 7 2010
Posts: 7
thomp wrote:
But since all you need is one simple piece of data there is an easy method. Append something to the price data to make it unique. For example, place an index number in front of each like this1:12.5, 2:3.0, 3:2.25, etc.

The #: can be stripped out using simple string functions.

var price = MyList.rawValue.split(":").pop();

So, you can still use the price as the export data.
Thanks Thom, that's a good solution although so far I've not been able to make it work probably because I don't know how or where to put the code.

At the moment I'm using formcalc in the cells, when I switch to javascript the whole thing grinds down to a halt.

In the frames field I have

if (this > "") thencanvas = ""endif

and in the price field (which totals all the columns is:

Size*QtyField+QtyField*AltPrice+QtyField*mount+QtyField*frame+QtyField*canvas
I can see from your code example that you are splitting the data into an array and discarding the first element. How would I access frames.option.value which I assume would need to be the 'rawvalue' element in your example?

I also assume that I cannot mix formcalc with javascript so would that mean that I need to convert all fields to javascript?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Form calc and JavaScript have different syntax. For example, the FormCalc "if" block above would translate to JavaScript like this:
if(this.rawValue > "")canvas.rawValue = "";

I can't really say anything else without more data. Where (what event on what element) the code is placed depends entirely on how the form is organized. For example, if the "price" from the droplist is used in a calculation then you split the price out of the list value in the calculation script.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

louiscar
Registered: May 7 2010
Posts: 7
Thank you Thom, It's reassuring that I can stay with formcalc for this. I'll have a play when I've a bit more time (I've used manual forms for my latest shoot). Perhaps if I hit on a stumbling block I can seek your advice ?

Louis