Highlighted

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

Michael_Eisenma

03-03-2009

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

Replies

Highlighted

Michael_Eisenma

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.
Highlighted

Michael_Eisenma

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 ????
Highlighted

Steve_L_Walker

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
Highlighted

Michael_Eisenma

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.
Highlighted

Michael_Eisenma

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 ????
Highlighted

pguerett

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.
Highlighted

Ryan_Lunka

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
Highlighted

Michael_Eisenma

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