Setting font size for multiple text fields with button

Lorezt

05-04-2015

Hi. I have been on Adobe LiveCycle for awhile but I still have problems in optimizing scripts as I do not have any programming background.

I have multiple textfields and I would like to decrease its font size all together with a click of a button.

I went through the Adobe Community and found a helpful post and I took the script from it. However, as per the script below, I believe it can be optimized maybe using arrays. However, I have no idea how to go about it.

Can anyone help? Your suggestions / advice will be highly appreciated.


var currentSize = Signature.RepName.font.size;


var currentSize = Signature.RepPosition.font.size;


var currentSize = Signature.RepCompany.font.size;



var ptPlace = currentSize.indexOf ( "pt");


var currentSizeInt = currentSize.substr ( 0, ptPlace);


var newSizeInt = parseInt (currentSizeInt, 10) - 1;



// set that as the new font size ( adding the "pt" back on)



Signature.RepName.font.size = newSizeInt + "pt";


Signature.RepPosition.font.size = newSizeInt + "pt";


Signature.RepCompany.font.size = newSizeInt + "pt";





Replies

Highlighted

Lorezt

05-04-2015

Oh wow! Okay! I did a little reading and I think I figured it out!

Working the way I want it, and it definitely looks less messier.


var signaturelines = new Array("RepName", "RepPosition", "RepCompany");




for (i = 0; i < signaturelines.length; i++){



var currentSize = Signature.resolveNode(signaturelines[i]).font.size;



var ptPlace = currentSize.indexOf ( "pt");


var currentSizeInt = currentSize.substr ( 0, ptPlace);


var newSizeInt = parseInt (currentSizeInt, 10) - 1;



// set that as the new font size ( adding the "pt" back on)



Signature.resolveNode(signaturelines[i]).font.size = newSizeInt + "pt";


}