Copy link to clipboard
Copied
Hello there,
I'm trying to change the format of text depending on a text field value
I don't know where is the wrong in my code!
it's not working
what I want is:
make the text red bold and italic if Actual_lodgning_1 > lodging_per_diem_1
Thanks in advance
This is the code:
if(event.value>Number(this.getField("lodging_per_diem_1").value))
{event.target.textColor = color.red;}
else if(event.value < Number(this.getField("lodging_per_diem_1").value))
{
event.target.textColor = color.black
event.target.fillColor = color.transparent;}
Actual_lodgning_1
Copy link to clipboard
Copied
It will only work when the value of "Actual_lodgning_1" is changed and not when "lodging_per_diem_1" is changed.
Copy link to clipboard
Copied
The code seems fine. Where did you place it, exactly (under what event)?
And are there any errors in the JS Console when it runs?
Copy link to clipboard
Copied
To make the text italic you must change the font.
Copy link to clipboard
Copied
it's under custome validation script
there is no erros, it's not working!
Copy link to clipboard
Copied
It will only work when the value of "Actual_lodgning_1" is changed and not when "lodging_per_diem_1" is changed.
Copy link to clipboard
Copied
Yes, this is what I want to change, but also it's not working
Copy link to clipboard
Copied
Sorry , it's working now, I did a mistake, maybe I did not try to change Actual_lodgning_1
how could I change the font to italic?
font.HelvB
Copy link to clipboard
Copied
if(event.value>Number(this.getField("lodging_per_diem_1").value))
{event.target.textColor = color.red,
event.target.textFont = font.HelvBI;
}
else if(event.value < Number(this.getField("lodging_per_diem_1").value))
{
event.target.textColor = color.black
event.target.fillColor = color.transparent;}
<div>it's working 100%, I did not change the text, but I have to change it, Is there anyway to make it run automatically? when any value changes the color changes</div>
Copy link to clipboard
Copied
Use the script as calculation script.
Copy link to clipboard
Copied
it's working very will with as calculation script.
thank you very much
Copy link to clipboard
Copied
As Bernd said, use script as calculation and just a tip if you first enter value in "Actual_lodgning_1" it will still make text red although "lodging_per_diem_1" is empty because blank value is same as 0, so you might want to check in your script that "lodging_per_diem_1" is not empty or 0 before changing text to red and italic.
Copy link to clipboard
Copied
You should also change the conditions to cover the cases where the two values are the same. If you don't, you might end up with some fields in red and others in black, while they are both the same, which is not consistent.
Copy link to clipboard
Copied
See the textFont property here:
Copy link to clipboard
Copied
That's a mazing, thanks bro
Copy link to clipboard
Copied
Thanks for all of you
Gonna try this today
Find more inspiration, events, and resources on the new Adobe Community
Explore Now