Copy link to clipboard
Copied
Rich text formatting is selected.
this is a javascript question.
This is a calculated field for a form field.
I just want 1 variable, no array needed. I would like my variable to be bold, centered, and larger font.
What I currently have... which do nothing...
var val = getField("Products").value;
val.alignment = "center";
val.fontStyle = font.TimesB
No thank you. I'll try a different forum.
Copy link to clipboard
Copied
You must use span objects. Read the documentation in the Acrobat JavaScript Reference.
Copy link to clipboard
Copied
WIth all due respect, I have read it, that's why I'm here. Its vague instructions aren't solving my problem.
I want the variable val to be bold, center, and larger. Part of the code is:
var val = getField("Products").value;
if (typeof val === "object") {
for (i = 0; i < val.length; i += 1) {
aLines.push(val + ":\n\t " + oDescriptions[val]);
}
} else {
aLines.push(val + ":\n\t " + oDescriptions[val]);
}
// Set this field value
event.value = aLines.join("\r");
})();
Copy link to clipboard
Copied
Why didn't you change the properties of the field?
Copy link to clipboard
Copied
Your code seems to have no connection to setting a span object. Which, the documentation states, is an array. Not sure why you say no array is needed, what do you know that the authors don't?
Copy link to clipboard
Copied
That they haven't given me a specific answer. Professional programmers agent on forums for answered. I'll think of a third
Copy link to clipboard
Copied
The trouble with saying that documentation is vague is that it's very difficult to help you. Documentation is often vague, it's true, but it's often all we have. All we could do for reply is quote from the documentation. But for complex topics that means quoting a lot of material and you've already said it's too vague to help you. I suggest if still stuck you say exactly what the documentation seems to miss out or what exact words are ambiguous. That helps us to answer your specific questions and fill in gaps in your knowledge. And it shows us you are actually looking at the document, rather than expecting someone else to write the code, because we have sometimes found accusations of vagueness actually just mean the work hadn't been done.
Copy link to clipboard
Copied
In http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf , there's spans[0] through spans [3]; I don't want to have to type each text out that could result. I want a one size fits all for all variables, especially as I add more
Copy link to clipboard
Copied
You don't actually need Rich Text to be checked if you aren't going to have multiple styles in the field. The problem you are having is that you are trying to set field properties on the field value rather than the field object itself. You were also using the wrong property name for the font.
See corrected code below.
var val = this.getField("Products");
val.alignment = "center";
val.textFont = font.TimesB
Copy link to clipboard
Copied
Thanks for the correction... nothing happened. The entire field is still left aligned and not bold
Copy link to clipboard
Copied
Where exactly are you putting the code?
Copy link to clipboard
Copied
(function () {
// Initialize some variables
var i, aLines = [];
// Associate states with a description
var oDescriptions = {
"Term" : "\nIssue ",
"Term - " : "This is a term with return of premium available",
"Term - " : "\nIssue Ages:",
"Whole Life -" : "This is a whole life"
}
// Get the selections from the list box
var val = this.getField("Products").value;
val.alignment = "center";
val.textFont = font.TimesB;
if (typeof val === "object") {
for (i = 0; i < val.length; i += 1) {
aLines.push(val + ":\n\t " + oDescriptions[val] + "\n===================================================================================="); //This is the line break I am using that I am trying to replace
}
} else {
aLines.push(val + ":\n\t " + oDescriptions[val]);
}
// Set this field value
event.value = aLines.join("\r");
})();
Copy link to clipboard
Copied
This is wrong:
nathanm54209085 wrote
...
var val = this.getField("Products").value;
val.alignment = "center";
val.textFont = font.TimesB;
...
You can change the properties of the field.
Copy link to clipboard
Copied
I haven't changed the properties of the field... BECAUSE AS I HAVE STATED, ONLY THE VAL HEADERS NEED TO BE DIFFERENT
Copy link to clipboard
Copied
nathanm54209085 wrote
I haven't changed the properties of the field... BECAUSE AS I HAVE STATED, ONLY THE VAL HEADERS NEED TO BE DIFFERENT
I don't see this information in your posting.
Again: When you want different text styles in one text field you must use span objects and rich text formatting.
Copy link to clipboard
Copied
Again: not to be rude, I'm here for a solution. Not a homework assignment
Copy link to clipboard
Copied
I give up. Good luck!
Copy link to clipboard
Copied
What happens when you change the property of the field?
Copy link to clipboard
Copied
A hint: you need to work with the field properties, not the value properties. So you have a .value that is quite wrong.
Copy link to clipboard
Copied
Can I please get the answer... I don't care about hints, vague ideas, homework assignments, suggestions to Google, or repeating what I've already said.
I just want it to work
Copy link to clipboard
Copied
Ok. The last bit of code had ".value" on the first line. Take it off, it does not belong.
Commentary: You have made an error by putting it there and refusing to remove it despite repeated attempts to send you in the right direction. Look at the description of the Field class, and its properties. Don't assume that "value" means any more than exactly what it says, don't try to use what you know about English to extrapolate.
Copy link to clipboard
Copied
I've tried it without or with it. Still no font or alignment change.
Commentary: if you highlight my text, press Ctrl + c, then Ctrl +v into the reply field. You can make the exact changes I've been requesting, then click post. I will get my solution that I've been begging for, and you'll get a well deserved thank you. And then this forum will be vindicated as a forum, not a tutoring session.
Copy link to clipboard
Copied
Please post the specific code you are now trying to use. Without the .value where I said. It's generally impossible to know what code someone is now using by the time you factor in inexperience, typos and wild frustration. Yes, wild frustration, I've been programming for decades and that is a continuing normal experience that never goes away.
Copy link to clipboard
Copied
(function () {
// Initialize some variables
var i, aLines = [];
// Associate states with a description
var oDescriptions = {
"Term" : "\nIssue Ages:\t\t10 Y",
"Term - Am" : "This",
"Term - " : "\nIssue Ag",
"Whole Life - Amer" : "This is a whole life"
}
// Get the selections from the list box
var val = getField("Products").;
if (typeof val === "object") {
for (i = 0; i < val.length; i += 1) {
aLines.push(val + ":\n\t " + oDescriptions[val] + "\n====================================================================================");
}
} else {
aLines.push(val + ":\n\t " + oDescriptions[val]);
}
// Set this field value
event.value = aLines.join("\r");
})();
Copy link to clipboard
Copied
I'll need to see the actual form before supplying any more help.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now