on 02-05-2015 8:29 AM
Hello Experts,
I have a requirement where in i need to adjust the font of the field dynamically based on the length of the value.
There is a less space in the adobe form layout and if there is long length (Above 50 Char) value coming then it is showing in multiple lines overlapping on another field.
I just want to dynamically pass the Font to field.
BR,
Nikhil Kulkarni
Hi,
That's easy using Javascript:
You can use e.g. the layou_ready event of the control to be formatted and add some JavaScript:
get the lenght of the text:
... String(yourtextfield).lenght ...
then format the text:
yourtextfield.font.size = "8pt";
regards
Sven
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sven,
Thanks alot for your reply. My field name is AGR_NAME , so i am writing the following logic and is not working. Please correct me where i am going wrong. Many thanks.
agr_name is my field name.
data.#pageSet[0].Page1.AGR_NAME::ready:layout - (JavaScript, client)
var len;
len = agr_name.length;
if (len < 3)
{
this.font.size = "20";
}else {
this.font.size = "3";
}
Do i need to change some thing in the above java script code which i have written in Layout:ready language : Java script Run at : Client.
BR,
Nikhil Kulkarni
Hello Sven Messmer ,
I wrote this one and still no change in the layout. All components for Java script is in place. I checked hiding of fields and it worked.
Below is the Code. Its not working. I tried specifying font as 20pt and 20. Both didnot reflect.
data.#pageSet[0].Page1.AGR_NAME::ready:layout - (JavaScript, client)
var len;
len = string(this.AGR_NAME).length;
if (len < 3)
{
this.font.size = "20pt";
}else {
this.font.size = "3pt";
}
BR,
Nikhil Kulkarni
Hi,
For me this works perfectly: this.font.size = "10pt";
It works in both master page and content. It seems like your field is in the master page.
May be you can check if your length is returned correctly. --> use an additional textfield to output the length for testing.
An additional check to do:
In transaction SFP, Menu Utilities -> Settings, switch trace level to "Very detailed trace". Once displaying your form in preview mode, check the attachment "error.pdf" --> here you'll find script errors if there are some.
regards
Sven
Hi Nikhil,
I've just recently worked on a few forms that were copied from SAP that had this exact code (in FormCalc). Within the initilize event:
var ln = Len($.rawValue)
if (ln <= 125) then
$.font.size = "8 pt"
elseif (ln <=135) then
$.font.size = "7 pt"
else
$.font.size = "6 pt"
$.para.lineHeight = "7 pt"
endif
Julie
Hi Nikhil,
Can you put a TextField onto the screen and on the Initialize event of that TextField put the following JavaScirpt code:
this.rawvalue = string(this.AGR_NAME).length;
This way you can check the value returned, maybe you have to build an extra check and is "len < 3" not enough.
Kind regards,
Niels De Greef
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.