Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to set radiobutton values based on some input values?

Avatar

Former Community Member
LCD 8.0

I have a table with 5 rows - each row has a checkbox in it.



The user can select 0 - 5 checkboxes. Based on the number of selected checkboxes, I need to dynamically 'press' a radiobutton (out of 5) to show the corresponding Risk level - If 2 checkboxes are checked, I need to press radiobutton #2, if 3 checkboxes the 3rd radiobutton, etc..



I can get the 1st one to work, but can't seem to be able to change it to any other radiobutton after the first.



What I do is sum the # of checkboxes checked, and try to set the raw.Value of the radiobutton = 1.



>var orgcnt = sum( PDF_CONTAINER.ConceptPage1.RisksPositioned.ORGRISKS.DATA[*].RISK_IND )



>if ( orgcnt == 1 ) then >PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1.cell3.RadioButtonList.NoRisk.rawValue = 1

>endif



>if ( orgcnt == 2 ) then >PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1.cell3.RadioButtonList.MinorRisk.rawValue = 1

>endif



If I select 1 Checkbox, the first radiobutton IS pressed, however, when I select a 2nd checkbox, the 2nd radiobutton is NOT pressed and also blanks out the 1st radiobutton.



any ideas?

thanks,

rp.
5 Replies

Avatar

Former Community Member
Yes I know exactly what the issue is. The RISK_ASSES1 subform has multiple instances based on which row your are in. So to change the 2nd row the exoxpression would be:



PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1[1].cell3.RadioButtonList.NoRisk.rawValue



Note that the occurance numbers are 0 based and by default if no occurance is specified then the 0 occurance is used.



Now when using the occurances in an expression you cannot simply replace the ocuurance with a counter or a variable as it will not get interpretted within the expression.. Also you can use the this.parent.index to know which instance of the subform you are on.



So the way to address that field would be:



xfa.resolveNode("PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1[" + this.parent.index + "].cell3").RadioButtonList.NoRisk.rawValue

Avatar

Former Community Member
Yes I know exactly what the issue is. The RISK_ASSES1 subform has multiple instances based on which row your are in. So to change the 2nd row the exoxpression would be:



PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1[1].cell3.RadioButtonList.NoRisk.rawValue



Note that the occurance numbers are 0 based and by default if no occurance is specified then the 0 occurance is used.



Now when using the occurances in an expression you cannot simply replace the ocuurance with a counter or a variable as it will not get interpretted within the expression.. Also you can use the this.parent.index to know which instance of the subform you are on.



So the way to address that field would be:



xfa.resolveNode("PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1[" + this.parent.index + "].cell3").RadioButtonList.NoRisk.rawValue

Avatar

Former Community Member
Paul,



thanks for your input.



However, I'm not trying to change radiobuttons in Row2 - I'm trying to change a set of 6 radiobuttons in my Row1.Cell3



I will always and only have two rows in my table. This first row is named



PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.

b RISK_ASSES1



and the second row is named



PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.

b RISK_ASSES2



In Cell3 of each of those rows, I have a Radiobutton group with 6 radiobuttons (named NoRisk, MinorRisk, SmallRisk, ModerateRisk, VeryRisky, CriticalRisk).



What I'm trying to do is "press" one of those radiobuttons based on some other variable's value.



Here's a sample bit of code that checks if my variable = 3, then "press" the 3rd radiobutton



] if ( orgcnt == 3 ) then

PDF_CONTAINER.IdeaSheetPage2.RiskAssesSubform.RiskTable.RISK_ASSES1.cell3.RadioButtonList.SmallRisk.rawValue = 1



endif



But, I'm not getting a radiobutton pressed.



EDIT: by the way, i'm sure my summed value is coming back because I placed it in a message box & see the correct number.

Avatar

Former Community Member
It is always much easier if I can see what you are referring to ...can you send the form and an explanation to livecycle8@gmail.com and I will have a look.

Avatar

Former Community Member
OK, I found the solution - I was trying to set the individual radiobuttons to ON/OFF, but this did not work.



Instead, I should have been passing the radiobutton value to my radiobuttonlist and setting it there.



thanks for your help.

rp.