Expand my Community achievements bar.

SOLVED

Conditional Radio Buttons

Avatar

Former Community Member

Okay I have a 2 page document. On Page1 I have radio buttons: RadioGroup1; radio1 = 0, radio2 = 1, radio3 = 2; RadioGroup2; radio4 = 0, radio5 = 1, radio6 = 2. On Page2 I have a textbox that will display sentences based on the selection from the Radio Groups. If the person selects radio2 or radio3 the following will be displayed in the textbox on Page2; "Group 1 is greater than 0". If the person selects radio5 or radio6 the following will be displayed in the textbox on Page2; "Group 2 is greater than 0". If the person select a combination of those, they will get both messages to display together. I tried using the "change" event on each of the Radio Groups.

topmostform.Page1.RadioGroup1::change - (JavaScript, client)

If (this.rawValue >

0)

{

Page2.textbox.value ("Group 1 is greater than 0. \n");

}

topmostform.Page1.RadioGroup2::change - (JavaScript, client)

If (this.rawValue > 0)

{

Page2.textbox.value ("Group 2 is greater than 0. \n");

}

Nothing is displaying in the textbox. Any help would be grateful.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Okay I am back at a computer!

The if/else statement could look like this:

if (this.rawValue > 0)

{

     Page2.textbox.rawValue = "Group 1 is greater than 0. \n";

}

else

{

     Page2.textbox.rawValue = "";

}

Hope that helps,

Niall

Assure Dynamics

View solution in original post

7 Replies

Avatar

Level 10

Hi,

I am inclined to use the click event of the radioButton exclusion group for this type of operation. You would then use this.rawValue in the if statement.

When using the change event you need to use the xfa.event.change instead of this.rawValue. This is because the user's selection has not registered by the time the change event fires. Hence, why my "personal" preference is to use the click event.

Also when setting the value of the textbox object, you also need to use .rawValue and not .value.

Niall

Avatar

Former Community Member

Okay I changed my code to reflect your suggestions;

0)

topmostform.Page1.RadioGroup1::click - (JavaScript, client)

If (this.rawValue >

{

Page2.textbox.rawValue("Group 1 is greater than 0. \n");

}

topmostform.Page1.RadioGroup2::click - (JavaScript, client)

If (this.rawValue > 0)

{

Page2.textbox.rawValue ("Group 2 is greater than 0. \n");

}

Still nothing is being displayed.

Avatar

Level 10

Hi,

It may just be the way the code snippet is pasted into the post, but the "if" in the statement should be a lowercase 'i".

The first one is missing "0)" in the if statement, but I am guessing that you have this in the script.

I am sorry, but I am not firing on all cylinders, the script settign the value of the textbox is incorrect. I didn't spot that until now:

if (this.rawValue > 0)

{

     Page2.textbox.rawValue = "Group 1 is greater than 0. \n";

}

That should work,

Niall

Avatar

Former Community Member

That allowed the sentences to be displayed, but doesn't take them away if the person re-clicks another option. For example; If they decided to change one of the groups back to 0. It also only allows for one sentence at a time. What about addItem and deleteItem? Or are they just used for dropdown lists?

Avatar

Level 10

Hi, you need to add an else statement after the if statement. For example, if a condition/test is true then do something, else do something different. I can't give an example now but if you search the forums for "else" you should find some. addItem and removeItem are for list objects only. Niall

Avatar

Correct answer by
Level 10

Okay I am back at a computer!

The if/else statement could look like this:

if (this.rawValue > 0)

{

     Page2.textbox.rawValue = "Group 1 is greater than 0. \n";

}

else

{

     Page2.textbox.rawValue = "";

}

Hope that helps,

Niall

Assure Dynamics