Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Radio Buttons

Avatar

Former Community Member
I have designed a form in which there are several criteria the user needs to either verify or decline verification. Each set of criteria asks the user to click a nearby radio button, and choose the radio button for either "verify" or "decline verification". I would also like to give the user an alternate choice at the top of each set of related criteria that says "verify all" and when this radio button is chosen, I would like all of the corresponding "verify" radio buttons in that particular set of criterion to automatically fill in. This is a fairly simple task but I know nothing about java scripting and would appreciate anyone guiding me in this process. I must admit that I am making the assumption that this would require scripting as opposed to some other simpler function.
5 Replies

Avatar

Former Community Member
Mr. Badzmierowski,



Not too tough a problem to solve.



Here is the js you could use. This is a simple solution and would require you to add it to all the RB groups you create. There would be another solution that would require the addition of Script Object, but for now this will get you going.



//Place this code in the "click" event of the Verify All box. (I would use a checkbox for this box.)



if (this.rawValue == 1) {

RB1.Verify.rawValue = 1;

//RB# = RadioButton group name for that choice. Verify would be the radio button you want checked.

RB2.Verify.rawValue = 1;

//Add more as needed for all choices

}



Again this is simple code and would require a lot of repeating if you have a lot of choices.



Rick Kuhlmann

Avatar

Former Community Member
Thank you so much for taking the time to resoond! I really apprecaite it. However, In Lifestle Deesigner 8, whered do I enter this script? If I right cick on the check box, and then choose the object palette, the only possible place I see to place the script is under the values tab, where there are spots for an empty message and for a validation script message. This is very confusing as there is also a check box for "error" in the validation script message area, and this seems to logically imply that if I put the script there, the script will only execeute if there is an error.

Avatar

Former Community Member
Mr. Badzmierowski



Javascript would placed on an event handler in the Script Editor. To access the Script Editor go to the menu and select Window/Script Editor.



The Script Editor has a number of events. For this javascript I would place it in the "click" event as described in my first post.



If you have problems finding the Script Editor just look in Help.



Rick Kuhlmann

Avatar

Former Community Member
Her ius the script I have placed in the bwscrsipt editor for the click event associated witrh the aappropriate check box:



----- topmostSubform.Page3.CheckBox3::click: - (JavaScript, client) --------------------------------



if (this.rawValue == 1) {

RadioButtonList[2].Verify.rawValue = 1;

if (this.rawValue == 1) {

RadioButtonList[3].Verify.rawValue = 1;

if (this.rawValue == 1) {

RadioButtonList[4].Verify.rawValue = 1;

if (this.rawValue == 1) {

RadioButtonList[5].Verify.rawValue = 1;

if (this.rawValue == 1) {

RadioButtonList[6].Verify.rawValue = 1;

if (this.rawValue == 1) {

RadioButtonList[7].Verify.rawValue = 1}



I formatted and spaced everything exactaaly as you had indicated. When I save the from and reopeen it to fill it out, nothing happens when I click in the check box except that the appropriate "X" appears in that check box - the corresponding radio buttons are not affected at all. Please help!

Avatar

Former Community Member
Mr Badzmierowski,



First I would have just one if statement and then group the rawValue statement under that one if statement



So it would look something like this:



if (this.rawValue == 1) {

RadioButtonList[2].Verify.rawValue = 1;

RadioButtonList[3].Verify.rawValue = 1;

RadioButtonList[4].Verify.rawValue = 1;

...

}



Second, because you are using a RadioButtonList[X] naming convention you have to preface each rawValue statement with:

xfa.resolveNode. So the statement would look like this"



xfa.resolveNode("RadioButtonList[X].Verify").rawValue = 1;



So replace the RadioButtonList[X].Verify.rawValue = 1; statements above with: xfa.resolveNode("RadioButtonList[X].Verify").rawValue = 1; but keep the statements together under the one if statement.



The other solution would be to rename your verify radio button groups to different names such as Verify1, Verify2, etc. Then you could get away with the statements as you currently have them.



Rick Kuhlmann