Expand my Community achievements bar.

SOLVED

Can an if statement reference multiple radio buttons?

Avatar

Level 1

I need to write a script that if two check boxes or radio buttons are selected, then an action will be performed.

if (condition1 && condition2);

     {action}

so I have this as my code for my button:

form1.page66.RadioButtonList.#field[0]::change - (JavaScript, client)

if(this.rawValue == 1 && form1.Intro.RadioButtonList[0].CN.rawValue == 2);

     {Intro.presence = "hidden"};

however, the action does not perform.

1 Accepted Solution

Avatar

Correct answer by
Level 10

I see a syntax error in your code.

Here is the corrected one.

  

if(this.rawValue == 1 && form1.Intro.RadioButtonList[0].CN.rawValue == 2)

{

     Intro.presence = "hidden";

}

Thanks

Srini

Note: rawValue was also missed in the syntax. You need to have that property to get the selected value in JavaScript.

Message was edited by: Srini Dhulipalla

View solution in original post

3 Replies

Avatar

Level 10

The problem is you can not get access to rawValue property in the Change event.

So move the code to Click event instead to make it to work.

Thanks

Srini

Avatar

Level 1

Thank you,

I updated my code but I think I am still doing something wrong. Its performing the action with only one condition being true.

Button 1

Button 2

Button 3

Button1a

Button2a

Button3a

If button 1 and button2a are selected, then hide page Intro.

Updated code:

form1.page66.RadioButtonList.#field[0]::click - (JavaScript, client)

if(this == 1 && form1.Intro.RadioButtonList[0].CN == 2);

    {Intro.presence = "hidden"};

it is hiding page Intro without both conditions being met.

Avatar

Correct answer by
Level 10

I see a syntax error in your code.

Here is the corrected one.

  

if(this.rawValue == 1 && form1.Intro.RadioButtonList[0].CN.rawValue == 2)

{

     Intro.presence = "hidden";

}

Thanks

Srini

Note: rawValue was also missed in the syntax. You need to have that property to get the selected value in JavaScript.

Message was edited by: Srini Dhulipalla