Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Help! Basic if statement to validate radio button

Avatar

Former Community Member
I cannot figure out this simple problem: what I want is to add text to the form depending on what radio button is selected. Should be a really easy "if" like "if radio1=x then y" but I can't get the syntax and I don't really know what to do for "y" part to make it write text. Can anyone show me what I'm missing?
11 Replies

Avatar

Former Community Member
You need to have a text field in which you want to show the text.. say it's called TextField1 for instance, and is in subform1.



give the radio buttons values (object, binding, specify item values)

for the radiobuttonlist click event



if (this.rawValue ==1)

{ subform1.TextField1.rawValue = "blaaaa"}

if (this.rawValue ==2)

{subform1.TextField1.rawValue = "fooo"}

else

{subform1.TextField1.rawValue = "defaultText"}



hth

s

Avatar

Level 7
See Help with Check box Question, http://www.adobeforums.com/webx/.3c053694, for code to test a check box, just change the "presence" property to the "rawVale" to set the field's contents.



You also might want to look at "Creating Radio CheckBoxes", http://www.acrobatusers.com/tutorials/2007/js_radio_check_box/ , and remember radio button and check boxes are similar except radio buttons allow only one selection and after a selection is made one must always be checked.

Avatar

Former Community Member
Hmm, I keep getting a syntax error on the first brace. This is what I've got:



----- form1.#subform[0].RadioButtonList::click: - (FormCalc, client) -------------------------------



if (this.rawValue == 1) {

subform1.TextField1.rawValue = "You picked Choice 1";

}

if (this.rawValue == 2) {

subform1.TextField1.rawValue = "you picked choice 2";

}

if (this.rawValue == 3) {

subform1.TextField1.rawValue = "You picked choice 3";

}

else {

subform1.TextField1.rawValue = "Please select one of the radio buttons";

}

Avatar

Former Community Member
Okay, I got rid of that by changing to JavaScript but now the message only seems to work with the third radio button selected: the first two cause the "else" message to be displayed. Any ideas?

Avatar

Level 7
The syntax is for Acrobat Forms JavaScript not LiveCycle Designer FormCalc or JavaScirpt.



if (this.rawValue == 1) then

subform1.TextField1.rawValue = "You picked Choice 1";



elseif (this.rawValue == 2) then

subform1.TextField1.rawValue = "you picked choice 2";



elseif (this.rawValue == 3) then

subform1.TextField1.rawValue = "You picked choice 3";



else

subform1.TextField1.rawValue = "Please select one of the radio buttons";

endif



Or you could try using the switch statement:



switch (Str(this.rawValue)) {

case "1":

subform1.TextField1.rawValue = "You picked Choice 1";

break;

case "2":

subform1.TextField1.rawValue = "you picked choice 2";

break:

case "3":

subform1.TextField1.rawValue = "You picked choice 3";

break;

default:

subform1.TextField1.rawValue = "Please select one of the radio buttons";

break;

}

Avatar

Former Community Member
Augh, okay, fixed that.



Real problem now: I need to have a field that can be adjusted by more than one set of radio buttons. By that I mean that when I click a button in List1 it puts one line in the text box and when I click a button from List2 it adds a new line without removing the first one, and so on and so on.



Is this possible? Maybe with a list box?

Avatar

Level 7
Yes, you can use the "Concat()" function in FormCalc to join two character strings into one new string.

Avatar

Former Community Member
Or just this.rawValue += "\r" + "blaa" which works in javscript.

Avatar

Former Community Member
I think problem is here



switch (Str(this.rawValue)) {

case "1":

subform1.TextField1.rawValue = "You picked Choice 1";

break;

case "2":

subform1.TextField1.rawValue = "you picked choice 2";

break:

case "3":

subform1.TextField1.rawValue = "You picked choice 3";

break;

default:

subform1.TextField1.rawValue = "Please select one of the radio buttons";

break;

}




kraloyun


yuju


fotoput


resim

Avatar

Former Community Member
Am trying to write a while statement in a pdf form and am not having any luck. Any suggestions? I'm trying to say that while widget is over 600 then its value will be $25 each 100 over 600 and while widget is greater than 1000 then its value will be $45 each 100 over 1000. Any suggestions?