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

Do text field settings override Javascript?

MMWilliams
Registered: Aug 23 2010
Posts: 16

Hi.

I have a read-only text box that I want to have bold and non-bold text in. I found a piece of code that seems like it will work to make certain sections bold, and am trying it out in a few different places in my javascript (again, way new at all this).

I can't get it to work, and am not sure if it's where I'm placing it in my script, or if the settings in the text field are overriding it? Currently the text field is set as Helvetica, and my code looks like this:

(function () {

// Get the value of the Time field
var v1 = getField("Time").valueAsString;

//document.write("Time".bold())

// Get the value of the Description field
var v2 = getField("Call Activity/Description").valueAsString;

// Get a reference to the Log field and get its value
var f3 = getField('Calls and Activity');
var v3 = f3.valueAsString;

// Append the Time and Description text to the Log
// starting on a new line
// v3 = old log value
// \r = carriage return
// v1 = time value
// v2 = description
f3.value = v3 + "\r" + v1 + " - " + v2;

})();

I need the Time data to appear bold, and am trying this code: document.write("Time".bold()) but am not sure where to put it.

Any suggestions?

Martha

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
If you want to do something like that you will need to set up the field to allow "Rich Text" and then use JavaScript to create the appropriate "spans". The code you're using (document.write...) is not used for creating the rich text for a field value.

More information about using JavaScript to create rich text field values is in the Acrobat JavaScript reference.