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

Expandable text box

ppachen
Registered: Jan 12 2007
Posts: 6

I am working to create an expandable text box that will enlarge as the user enters in information. The box starts out as one line, but should end up as multi-line as the form is filled.

The JavaScript is entered as a Keystroke script. It seems to be working for the most part, except when the box increases in size, I must use the resetForm feature to apply the size change. When this happens, the focus is taken away from the text box. I want the user to be able to enter the text without interruption.

It would make sense to use the setFocus feature, although it does not seem to work when I have it in the Keystroke script. I was able to add a button the sets the focus back to the text box, but I want it to be automatic.

Any ideas??

if (event.fieldFull) {
var b = this.getField("Text1");
var aRect = b.rect;
aRect[3] = aRect[3] - 11.5;
b.rect = aRect;

this.resetForm([event.target.name]);
event.change = event.changeEx;
//b.setFocus();
}

maxwyss
Registered: Jul 25 2006
Posts: 255
The problem with this scenario is that you somehow have to get out of and back to the field in order to apply the size change (see code example with event.fieldFull).

Another possibility would be to use a multi-line field in any case. When filling out the field, the user can type in without interruption, and if the text gets beyond the field's capacity, a scrollbar appears.

In the Validate event (that should already do it, if not, go ahead to the onBlur event), evaluate the field's value and resize it. If the text looks "weird", you will also have to re-set the field's value (not reset, but set again).

Hope this can help.

Max.