Shouldn't this script change the color of a field ?

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

if( this.rawValue == "1") { this.border.fill.color.value == "255,0,0"; }

Replies

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

This is the way it shows up in <View> <XML code><br /><br /><script contentType="application/x-javascript">(this.rawValue =="1"{ this.border.fill.color.value == "255,0,0";})<br /></script><br /><br />It doesn't do anything as originally displayed or as displayed here.

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

perhaps - I 'm missing something ..<br />I have the following.<br /><br /><field><br /><format><br /><\script><br /> if(this.rawValue =="1"){ this.fillColor.value == "255,0,0";}) <\/script><br /></format><br /></field><br /><br />When the field is set to 1 by the user or by any other means - <br />won't the <format> directive ensure that the script is executed ????

Avatar

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

198 likes

Total Posts

1,435 posts

Correct reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Steve_L_Walker
Level 9

Likes

198 likes

Total Posts

1,435 posts

Correct reply

212 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Steve_L_Walker
Level 9

03-03-2009

smde,



I am not sure what you are trying to accomplish but I would discourage directly modifying the XML source.



Typically a fill colour change is performed in response to an event such as a failed validation. In this case you would put your script in the validation event for the applicable object.



Additionally, your script is not going to work because you are checking equality "==" rather than doing an assignment "=".



this.border.fill.color.value = "225,0,0,";



will change the fill colour to red.



Steve

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

Typo in the previous post - should read as :



if(this.rawValue == "1") {this.border.fillColor.value = "255,0,0"};



I have this in the *initialize event ...

and in the

*change event



and there is no color change in the field - as if nothing was happening.

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

and red is the desired color 🙂

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

03-03-2009

I must really be missing what is going on here .



I can't even get it to change color when I set the validate event check for the value of 1....

The field is a numeric field and I enter one - and the validate event has the simple if statement and ... no color change ....

Is there a cahnce that something is overriding the script logic altogether - is there a security setting or a preference condition that might explain this ????

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

04-03-2009

Why are you doing it on the initialize event. The data has not been set yet. Put it on the exit event first to make sure it works. Once you validate that it works put it on the FormReady event - data has been merged by then.

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

04-03-2009

Verify that your form is set up to be a Dynamic form. I find that many times, if you forget to change FROM a Static form, certain scripts work and certain ones don't. Also, try what Paul said. You may also want to try removing the quotes from your "1" in the "if" statement.



Hope this helps.



Ryan D. Lunka

Cardinal Solutions Group

rlunka@cardinalsolutions.com

Avatar

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
Michael_Eisenma
Level 2

Likes

0 likes

Total Posts

18 posts

Correct reply

0 solutions
View profile
Michael_Eisenma
Level 2

04-03-2009

The script is being run - it just isnt changing anything .....

I intentionally pranged the script so that it would error out when it executed.

I set the javascipt debugger to run on erros and I got this message whne I modified the field -



missing ) after condition

1:XFA:Provider[0]:#subform[0]:Disclosure[25]:DisclosureAnswerFlag[0]:change



so changing it back to the original syntax ... the script is running - but is having no effect ... hmmmmm