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

Fitting drop down list depending on the length of selected list item

djinges
Registered: Jun 27 2007
Posts: 55
Answered

Hi all,

could someone tell me, how to fit the length of a drop down list depending on the length of selected item. It would be great!

So let me tell you in details what exactly i want to do. Given a drop down list with specified length. Depending on the length of selected item of this list, you want to fit the whole length of the list on change.

Trying to do it, but i have not find a solution yet :(

Thanks to your help in adv!

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can't. The lentgh of the dropdown is controled by Acrobat. It decides dynamically how large the list should be so that its visible to the user.

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

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

you possibly can solve this with a subform, an alias text field and JavaScript.
I have a developed a sample form, that does what you want.

You can download it here.
[url]https://acrobat.com/#d=kvGJ4kTvXaZHj5g6LJpP6Q[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ahh yes, faking it with a fabricated control. Brilliant solution.

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

djinges
Registered: Jun 27 2007
Posts: 55
Thanks thomp, thanks radzmar for your help!

Djinges
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
;-)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

djinges
Registered: Jun 27 2007
Posts: 55
First of all, kudos to radzmar! Great idea!

@thomp: What would you think about augmenting futher attributes of the attributes of the drop down list? From my point of view of the handsome layout on the formular I would say, you could augment the attribute named 'reserve' of the caption from a drop down list to writeable, so you can say the current length of the drop down list is
the length of the caption reserve
+ the length of the selected item
+ offset (user's defined)

There is not more modification in the sdk in LCD and we all can profit from it.

I think, this change would be welcome in greatest manner!


!! Sorry, it was wrong claim. The caption's reserve ist read- and writeable. Forget about it, thanks!
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
@djinges

Great idea too.

I just added a new dropdown that works with this method to my sample form.
Works pretty good, I think.
Have a look and give me your feedback.

[url]https://acrobat.com/#d=kvGJ4kTvXaZHj5g6LJpP6Q[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

djinges
Registered: Jun 27 2007
Posts: 55
Thanks radzmar again! Very useful hints!

Things i want to do is fitting object's length to given constant caption reserve, but with alterable length of input or selected item. Here is the sample.

With given drop down list with well-defined length and caption reserve, also the font size we can do:

if(xfa.event.newText != xfa.event.prevText) {// the size of Current Caption Reservevar CCR = parseFloat(this.caption.reserve.substr(0,this.caption.reserve.indexOf("m")));var CIL = xfa.event.newText.length; // the length of the current selected item// compute the points of selected itemCIL = CIL * parseFloat(this.font. .size.substr(0,this.font.size.indexOf("p")));// compute the current length of the selected item with destop publishing constantCIL = Math.ceil(CIL * (25.4 / 72)* .65); // .65 is the offset of font width, but isn't a good ideathis.w = (CCR+CIL)+"mm";}

It works, but is not realy fine. There is also (big) gap because of not knowning about the width of a single charakter.

What a pity! Maybe can someone else improve it!?

Best regards!