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

Align text in textfield and change font size

smilem
Registered: Apr 1 2008
Posts: 101
Answered

Hi, I have multiline textfield and tried to align my text using javascript onlick event of a button

TextField1_1.alignment = "justify";
TextField1_1.alignment = "left";
TextField1_1.alignment = "right";
TextField1_1.alignment = "center";

I have separate buttons for every style, but they do not seem to work. I'm using livecycle 8

how do I change font size using javascript?

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
have you looked into the Designer scripting reference?
There is no property named alignment.

To change the alignment between left, center, right, justifyAll, justify or radix use:
TextField1.para.hAlign = "center";
To change the font size:
TextField1.font.size = "12pt"

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

smilem
Registered: Apr 1 2008
Posts: 101
Well I read js_developer_guide.pdf

Page 72
Property Description Field properties
text alignment Text layout in text fields. alignment

Should I download some different reference if I use livecycle?
smilem
Registered: Apr 1 2008
Posts: 101
Also if I start typing inside the textfield then use dropdown to change the font size the font size does not change. When I delete everything with a delete button then start typing again it changes.

I need to add "if then" somewhere?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
1. LiveCycle Designer uses a different JavaScript than Acrobat does, so many methods and properties are different.
You can see the links to the reference manuals at the bottom of my post.

2. To change the fontsize through a drop down field use a script such as:
if (xfa.event.newText == "4"){TextField1.font.size = "4pt"}if (xfa.event.newText == "8"){TextField1.font.size = "8pt"}if (xfa.event.newText == "16"){TextField1.font.size = "16pt"}if (xfa.event.newText == "24"){TextField1.font.size = "24pt"}if (xfa.event.newText == "36"){TextField1.font.size = "36pt"}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

smilem
Registered: Apr 1 2008
Posts: 101
I used

var sNewSel = this.boundItem(xfa.event.newText);

switch (sNewSel)
{
case "1": // show row1 8
TextField1_1.font.size = "8pt"

break;

default: // unknown value -- do nothing
break;
}

But it seems the alignment buttons only work if the text is in textfield is pre-entered. If I change the text the alignment does not work somehow.
smilem
Registered: Apr 1 2008
Posts: 101
It seems I fixed it, the textfields format have to be set as "plain text only"
smilem
Registered: Apr 1 2008
Posts: 101
Thanks for your help.