Is there a way to script to change all of the text in a textField back to text color black ("0,0,0") if a user has changed the text color using the Form Field Text Properties Bar? It looks like that is done on a separate layer?
I tried this and it does not work:
Subform1.UpperSection.font.fill.color.value = "0,0,0";
and I tried:
Subform1.UpperSection.font.color = "0,0,0";
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You will have to go though each property of the rich text value looking for a textColor property, so something like this JavaScript in the exit event;
var spans = util.xmlToSpans(this.value.exData["##xHTML"].saveXML());
for (var i = 0; i < spans.length; i++)
{
if (spans[i].textColor && !color.equal(spans[i].textColor, color.black))
{
spans[i].textColor = color.black;
}
}
var xHTML = util.spansToXML(spans);
this.value.exData.loadXML(xHTML, false, true);
Using util.xmlToSpans() will lose some other formatting, as it only supports a subset of what is available. If that is a problem then you can use E4X or some other XML handling code.
Bruce
Views
Replies
Total Likes
Hi,
You will have to go though each property of the rich text value looking for a textColor property, so something like this JavaScript in the exit event;
var spans = util.xmlToSpans(this.value.exData["##xHTML"].saveXML());
for (var i = 0; i < spans.length; i++)
{
if (spans[i].textColor && !color.equal(spans[i].textColor, color.black))
{
spans[i].textColor = color.black;
}
}
var xHTML = util.spansToXML(spans);
this.value.exData.loadXML(xHTML, false, true);
Using util.xmlToSpans() will lose some other formatting, as it only supports a subset of what is available. If that is a problem then you can use E4X or some other XML handling code.
Bruce
Views
Replies
Total Likes
Thank you Bruce
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies