Expand my Community achievements bar.

SOLVED

Shrinking Text Fields

Avatar

Former Community Member

Hello everyone.  So I figured out how to simultaneously expand text fields, now I would like to simultaneously shrink them.  Here's the scenario: a client receives the form, enters 5 lines (or whatever) in a text field and the set of text fields expand.  Realizing they entered too much, they delete a line or two.  Unfortunately, the text fields do not contract.  Worst-case scenario: someone enters lots of information, deletes a bunch of it, and is stuck with a gigantic set of text fields when they only need a little space.  I would like it if the set of text fields would collectively assume the size of the largest entry and be no larger.  I'm attaching an example, and if anyone would like it before it gets unqueued, I will be happy to e-mail it to them.

Bonus question: I would like to do all of my scripting in JavaScript.  Unfortunately, I can't figure out how to get the reference to subsequent subform instances to work in JavaScript.  If you look in the "Delete" button, you will see it is scripted in FormCalc.  The only reason I do this is to get this

if (_Description_Value_Comments_and_Office_Comments.count==(this.parent.index+1)) & (_Description_Value_Comments_and_Office_Comments.count<>1) & (choice==4)) then

Description_Value_Comments_and_Office_Comments[this.parent.index-1].Any_other_property_of_this_type.rawValue="2"

endif

to work properly.  When I try to do something similar in JavaScript it doesn't seem to be able to handle this:

Description_Value_Comments_and_Office_Comments[this.parent.index-1].Any_other_property_of_this_type.rawValue="2"

I think it has something to do with the [this.parent.index-1] bit, but I don't know how to fix it.

Thank you all for your help.

Message was edited by: AJP256
Reason: changed "textboxes" to "text fields" because that's what I really meant

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

In relation to the height of the textfields, it would be easier if all of the textfields were in a row. That way you can do away with all of the script, whch is trying to maintain the height.

Also it makes it easier to add additional rows.

I am uploading a sample (note this would need tidying up).

Good luck,

Niall

ps, the file size seems v. large given that there are no graphics???

View solution in original post

13 Replies

Avatar

Correct answer by
Level 10

Hi,

In relation to the height of the textfields, it would be easier if all of the textfields were in a row. That way you can do away with all of the script, whch is trying to maintain the height.

Also it makes it easier to add additional rows.

I am uploading a sample (note this would need tidying up).

Good luck,

Niall

ps, the file size seems v. large given that there are no graphics???

Avatar

Former Community Member

Thanks Niall!  That was really helpful.  The tricky part was getting the add/delete behavior to be the way I had it previously (for the form I'm working on I really want the users to be forced to say yes or no), but I finally got it worked out.  I'm posting what I finally came up with below.

Avatar

Former Community Member

As to your PS, I'm not sure why this form is so large.  I don't have much context, so I can't judge for myself whether 500k is large for such a form.  If anyone has any ideas, I'd appreciate the help.

Avatar

Level 10

Hi,

Glad you got it working!!

I have looked at the form and I would recommed that you consider changing the font. Times New Roman (as a serif font) is not great for screens anyway.

There is a tab in the forms / properties for the save options.

Unchecking the options will help reduce file size, in particular "embeding font".

Your file started off at 500kb; not embeding Times New Roman, reduced this down to 16kb.

We use Myriad Pro font and I have changed this on your form. When this sans-serif font is embeded the file size is 150kb. Still an increase but not as bad as Times New Roman.

If you don't have Mryiad Pro, you will get a prompt when you open the form in LC. If this is the case I would recommend changing the font to a sans-serif font, which will hopefully be lighted than TNR.

Good luck,

Niall

Avatar

Former Community Member

Is there a simple way to universally change the font for an entire form?  It would be quite a pain to have to go back and change every single object in my entire form.

Avatar

Level 10

Hi,

The good news is YES.

If you select an object and click on the XML Source Tab (if you don't see it is available under the View menu).

This will take you straight to where that object is in the XML source. Now note down exactly what the old font is referenced. Then go back to the design view and change the font to what you want. Same thing go back to the XML and see how that new font is referenced.

08-07-2009 00-48-37.png

Once you have these two bits of info, you can do a "Find and Replace" within the XML Source (Edit / Replace...). Put in the two font references and "Change All". All you are changing is the bit inbetween the quotation marks.

Fingers crossed, when you preview the form, all of the text will be changed. Test your form and make sure you are happy with the layout, etc.

Then on to the next form...

Good luck,

Niall

Avatar

Former Community Member

AJP!

Can you help me with the script for textfield inside the table row to expand and shrink it depending on the content size? I've tried to look at your one but could not figure it out what part is doing it?

Thank you in advance

Avatar

Level 10

Hi,

just to say, I think that you can achieve what you want without script.

You can set an object like a textfield to expand automatically once the user tabs out of the field.

I am uploading a sample. There are lots of quirkes and settings to get right. But there are also some good threads on the forum.

Good luck,

N.

Avatar

Former Community Member

Naill,

Thanks for that trick, but when I use it the content of the doc disappearing after it reach the edge of the page?

I' ve ticked the box allow page breaks within the content.

I've tried to wrap the text fiel into subform - does not happening. I understood that sub form has to have a tick in 'allow page breaks within the content' by mine for some reason shaded?

Thanks

Alex

Avatar

Level 10

Hi Alex,

You need to specify that the data can be paginated. Select the page/content container and go to the Object/Pagination tab.

Below you will see that I have set it to overflow to the same content area as page 1 and I have set up an overflow leader.

When you get into flowed content, there a re a few things you need to set up, as to how you want the form to render. Once you have these, it should work consistently.

Hope that helps,

Niall

Avatar

Former Community Member

Alex-in the final example I posted (Pets with proper delete and text field behavior) the text field size isn't controlled by any scripts-it's solely a function of 1. allowing multiple lines in the text fields, 2. setting the text fields to "Expand to fit" under height in the Layout palette, and 3. the fact that they're part of a table.  The scripts are solely there to allow me (or whoever) to add and remove rows and such.

Avatar

Former Community Member

Niall,Thanks

It does work!!

But it messd up all layout of the form and if I need to add say text fiel it will be placed right next to the previous object and not where I need it? Or for some reason it throw the object at the very end of the last page?

Am I doing soemthing wrong?

Thanks

Avatar

Level 10

Hi,

Glad you got it working. I am out at the moment, so can't see the full thread.

When you have a flowed form LC will automatically place objects right up tight against each other.

A few points to bear in mind:

1 wrap all objects that don't need to expand in height into a positioned subform. Then put objects that need to expand into a flowed subform. These expanding objects should be adjacent to each other; so your form structure may look like:

Page 1 = flowed

- positioned subform

- positioned subform

- flowed subform

- positioned subform

- flowed subform

- etc.

I would go back to an earlier version of the form and group elements first; then only flow the subforms that contain expanding objects. Note you may have to update some of your scripts to take account of subform names.

In relation to objects in a flowed subform that are up against each other, you can set offsets in the layout tab to force a gap. Also you can use rectangles with no fill or border as spacers.

Whe placing objects on the form LC may put them outside of the subform you intended. You can drag them in the hierarchy view back into the correct positioned or flowed subform.

Hope that helps.

Niall