Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Using Radio Buttons to Change Text

Avatar

Level 2

Greetings,

Please forgive me if this has been asked and answered; I attempted to search for an answer.  I am currently working in Adobe Designer (complete newbie) and I am sure I need javascript (also a newbie) to accomplish the following: 

 

I have two radio buttons (1) Purchaser and (2) Contractor; there are multiple references throughout the document that should change to either "Purchaser" or "Contractor" depending on which of the radio buttons is selected. 

NOTE:  The radio buttons are grouped (porc)

NOTE:  Each of the "references" has a text field

NOTE:  Script exists but not working and I am attempting to remedy as this form is needed.

 

The following is the javascript present when looking at the radio button "group" in design mode:

____________________________________________________________________________

form1.Page1.sect1.porc::change - (JavaScript, client)
 
if (this.rawValue == "1") {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Purchaser";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Purchaser";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
xfa.resolveNode(“form1.Page1.nonCorporate.Name[0].caption.value.#text”).value = Name of Purchaser”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[1].caption.value.#text”).value = Street Address of Purchaser”;
xfa.resolveNode(“form1.Page1.nonCorporate.Name[1].caption.value.#text”).value = Name of Purchaser”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[0].caption.value.#text”).value = Street Address of Purchaser”;
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Purchaser";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
}
else {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Contractor";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Contractor";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
xfa.resolveNode(“form1.Page1.nonCorporate.Name[0].caption.value.#text”).value = Name of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[1].caption.value.#text”).value = Street Address of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Name[1].caption.value.#text”).value = Name of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[0].caption.value.#text”).value = Street Address of Contractor”;
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Contractor";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
}
 
form1.Page1.sect1.porc.purc::change - (JavaScript, client)
 
if (this.rawValue == "1") {
//xfa.resolveNode("form1.Page1.sect2.contractrTxt.text.value.text").value  = "Purchaser";
//xfa.resolveNode("form1.Page1.sect.proxysign").presence = "visible";
//xfa.resolveNode("form1.Page1.claimantSignature.Employee_Certify.caption.value.#text").value = "I certify that this claim is true and correct to the best of my knowledge and belief and that the claimant has not received reimbursement for these expenses.";
}
else {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Contractor";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Contractor";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
xfa.resolveNode(“form1.Page1.nonCorporate.Name[0].caption.value.#text”).value = Name of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[1].caption.value.#text”).value = Street Address of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Name[1].caption.value.#text”).value = Name of Contractor”;
xfa.resolveNode(“form1.Page1.nonCorporate.Address[0].caption.value.#text”).value = Street Address of Contractor”;
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Contractor";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
}
____________________________________________________________________________________________
Please provide detailed instructions, as I am new to javascript and the Adobe Designer interface.

Any assistance you can provide would be greatly appreciated.

Thanks in advance.

~J

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Use this: the first line was for your reference:

 

if (this.rawValue == "1") {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Purchaser";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Purchaser";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Purchaser";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
}
else {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Contractor";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Contractor";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Contractor";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
 
}

View solution in original post

10 Replies

Avatar

Community Advisor

Put various app.alert("test1"); inside your script to check at which line script is breaking. There might be an issue with som expressions in the script.

If you cant find it then share your form with me(vkatoch07@gmail.com).

Avatar

Community Advisor

I checked your form and I did two things to make it work:

1. Save as your form as "Adobe Dynamic XML form"

2. Remove all the script and use the below script in the click event of the radio group. It will work like butter :).

 

form1.Page1.sect1.porc::click - (JavaScript, client)
 
if (this.rawValue == "1") {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Purchaser";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Purchaser";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Purchaser";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
}
else {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Contractor";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Contractor";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Contractor";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
 
}

 

Avatar

Level 2

Thank you for your prompt reply and support.  Unfortunately, I have not had success; when I attempt to preview the PDF, nothing happens.  (I am sure I am missing something).  I have attached a screenshot in hopes you can assist me once again.  I truly appreciate you sharing your knowledge.

 

Thanks in advance,

J

Avatar

Correct answer by
Community Advisor

Use this: the first line was for your reference:

 

if (this.rawValue == "1") {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Purchaser";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Purchaser";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Purchaser";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Purchaser";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Purchaser";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Purchaser";
}
else {
xfa.resolveNode("form1.Page1.sect2.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page1.sect3.Name.caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.sect3.Address.caption.value.#text").value = "Address of Contractor";
xfa.resolveNode("form1.Page1.sect3.City.caption.value.#text").value = "City of Contractor";
xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[0].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[1].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Name[1].caption.value.#text").value = "Name of Contractor";
xfa.resolveNode("form1.Page1.nonCorporate.Address[0].caption.value.#text").value = "Street Address of Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt.value.#text").value = "Contractor";
xfa.resolveNode("form1.Page2.Corporate.contractorTxt2.value.#text").value = "Contractor";
//xfa.resolveNode("form1.Page1.sect3.SignatureField2.caption.value.#text").value = "Signature of Contractor";
 
}

Avatar

Level 2

Thank you, Vijay!  Just like you said, "It works like butter." I am so grateful for your prompt replies and knowledge.  Have an awesome day!

Avatar

Level 2

Greetings Everyone:

 

I am having a similar issue with the radio button functionality for another document.  I attempted to use the code of the solution provided but it is not working.  I updated the "target version," ensured I saved as "Dynamic XML," and I even went through to rename the objects in the hierarchy window to eliminate error.  Still nothing and I am relatively sure I am missing something once more.  Would it be possible to review my code:

 

form1.Page1.sect1.porc::click - (JavaScript, client)
if (this.rawValue == "1") {
xfa.resolveNode("form1.Page1.sect1.NotePurCon.value.#text").value = "Note to Purchaser";
xfa.resolveNode("form1.Page1.sect1.SectionIV.value.#text").value = "Section IV: Acceptance to be filled in by Purchaser";
//
}
else {
xfa.resolveNode("form1.Page1.sect1.NotePurCon.value.#text").value = "Note to Contractor";
xfa.resolveNode("form1.Page1.sect1.SectionIV.value.#text").value = "Section IV: Acceptance to be filled in by Contractor";
//

}

 

Also, would anyone have any good reference material for javascript; as I hate to burden the community with my challenges.

Any assistance you can provide would be greatly appreciated.

 

Thank you in advance.

~J

Avatar

Community Advisor

For these two fields, you have taken the text object, that's why not working.

Take textField instead and then set the value.

Avatar

Level 2

Thank you for the prompt reply.  I apologize for being unaware; however, when you say, "Take textField instead," do you mean to replace #text with #textField in the code?  Such as:

 

xfa.resolveNode("form1.Page1.sect1.NotePurCon.value.#textField").value = "Note to Purchaser";

 

Thank you for your patience and understanding.

 

 

Avatar

Community Advisor

Your script is fine. The issue is with "NotePurCon" field. Delete this field and drag it again from Object library.

Avatar

Level 2

You are AWESOME!  Thank you so much.  Fixing the one field as you suggested corrected everything.  I guess there was an issue with the text box (maybe I should not copy and paste text objects...LOL.  Lesson learned!).  I cannot thank you enough!