Using Radio Buttons to Change Text | Community
Skip to main content
Level 2
June 1, 2023
Solved

Using Radio Buttons to Change Text

  • June 1, 2023
  • 3 replies
  • 2077 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijay_Katoch

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";
 
}

3 replies

Vijay_Katoch
Community Advisor
Community Advisor
June 2, 2023

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

Vijay_Katoch
Community Advisor
Community Advisor
June 2, 2023

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";
 
}

 

JJazz77Author
Level 2
June 2, 2023

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

Vijay_Katoch
Community Advisor
Vijay_KatochCommunity AdvisorAccepted solution
Community Advisor
June 3, 2023

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";
 
}
JJazz77Author
Level 2
June 6, 2023

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

Vijay_Katoch
Community Advisor
Community Advisor
June 7, 2023

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

Take textField instead and then set the value.

JJazz77Author
Level 2
June 7, 2023

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.