Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

If/Then to control behavior/value of 3 Fields based on DropDown

sparrowce
Level 4
Level 4

My form has 3 fields I am needing to control their values and/or behavior based on dropdown value.   If the value is 'original', I'm needing the Current Value field to not be mandatory, and the 2 bottom fields to just return null.  If  'change' is selected, I'm needing Current Value to be required, and calculations performed on bottom 2 fields.    Below is what I have in the exit event (JavaScript) of the dropdown, which is named OrderType, but nothing is happening.  What am I missing, or do I have this on the wrong event or should I be using FormCalc?

Appreciate any help, thank you!

2-5-2013 10-26-13 AM.png

form1.#subform[0].OrderType::exit - (JavaScript, client)


if (this.rawValue == "Original")

{

    xfa.resolveNode("form1.#subform.value_curr").rawValue = "";

    xfa.resolveNode("form1.#subform.value_curr").mandatory = "disabled";

    xfa.resolveNode("form1.#subform.value_change").rawValue = "";

    xfa.resolveNode("form1.#subform.value_total").rawValue = "";   

}

else if (this.rawValue == "change")

{

    xfa.resolveNode("form1.#subform.value_curr").rawValue = "";

    xfa.resolveNode("form1.#subform.value_curr").mandatory = "error";

    xfa.resolveNode("form1.#subform.value_change").rawValue = xfa.resolveNode("form1.#subform[5].tblBOM.FooterRow.GrandTotal");

    xfa.resolveNode("form1.#subform.value_total").rawValue = value_curr + value_change;

}

1 Accepted Solution
Vjay_Reddy
Correct answer by
Level 5
Level 5

I have sent the updated document to ur mail ID. Please chk.

Thanks

Vjay

View solution in original post

8 Replies
Vjay_Reddy
Level 5
Level 5

Have you done the form properties settings ? To do the same

In the preview tab > Preview adobe XML Form as should be : Dynamic XML Form.I hope in the default tab > PDF Render Format has to be Dynamic.

If it doesnt work keep message box and see whether you are getting the message or not.

Vjay

sparrowce
Level 4
Level 4

Thank you.  It was saved as dynamic XML, bu the form properties were static pdf.  The default language was set to FormCalc, should it be JavaScript?  Have set it to dynamic rendering and tried both default languages and tried the messsage box.  Am not getting a message.  I put the message box before the IF code started. 

Vjay_Reddy
Level 5
Level 5

Hi Sparrocwce,

I have tried Its working for me as you expected. Can you share your file so that its easy for us to find the issue or mail me @ muchukotavijay@gmail.com.

Vjay

Vjay_Reddy
Level 5
Level 5

Hi ,

Change the below line it would work.

else if (this.rawValue == "Change")

I havent done any modification except that.

Thanks

Vjay

sparrowce
Level 4
Level 4

Thank you, I need to realize this is case sensitive and have corrected the line, but still not having any luck.  The test messsage box isn't firing up and neither are the bottom 3 fields being altered based on dropdown selection.  I have gone back through the form settings, but don't know what is different in why it won't work for me.

Vjay_Reddy
Correct answer by
Level 5
Level 5

I have sent the updated document to ur mail ID. Please chk.

Thanks

Vjay

View solution in original post

sparrowce
Level 4
Level 4

Thank you, that works great.  I appreciate the help, and am posting the changes you made in case anyone else has similar issues.  I will comment out the messages.  Thank you again!

xfa.host.messageBox("Hello World!");

if (this.rawValue == "Original")

{

    value_curr.rawValue = "";

    value_curr.mandatory = "disabled";

    value_change.rawValue = "";

    value_total.rawValue = "";   

    xfa.host.messageBox("End of original loop");

}

else if (this.rawValue == "Change")

{

    value_curr.rawValue = "";

    value_curr.mandatory = "error";

    value_change.rawValue = xfa.resolveNode("form1.#subform[5].tblBOM.FooterRow.GrandTotal");

    value_total.rawValue = value_curr + value_change;

    xfa.host.messageBox("End of Change loop");

}