Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Select a radio button via javascript

Avatar

Level 2

Is it possible to select a radio button using a script?

I'm trying to select a radio button with a value of 0 in a group called Department if a radio button with a value of 0 is selected in a group called TimeofCall.

I tried this and several variations:

if

((this.TimeofCall.rawValue == 0))

{

xfa.host.messageBox("Day is Checked.");

this.Department.rawValue

== 0;

}

I get the message so I know it is checking the TimeofCall group but I can't get it to select a radio button in the Department group.

Any ideas would be appreciated.

- Kevin

1 Accepted Solution

Avatar

Correct answer by
Level 10

You're syntax is a little messed up.

"This" is used to reference the current object.

So, assuming the value you are testing is the current object the basic statement should be along the lines of:

if (this.rawValue == 0){

RadioButtonList.fieldname.rawValue = 0;

}

//else {

//}

If you are testing a different field it would be:

if (fieldname.rawValue == 0){

RadioButtonList.fieldname.rawValue = 0;

}

//else {

//}

Hope that helps! Going from memory at the moment...

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

You're syntax is a little messed up.

"This" is used to reference the current object.

So, assuming the value you are testing is the current object the basic statement should be along the lines of:

if (this.rawValue == 0){

RadioButtonList.fieldname.rawValue = 0;

}

//else {

//}

If you are testing a different field it would be:

if (fieldname.rawValue == 0){

RadioButtonList.fieldname.rawValue = 0;

}

//else {

//}

Hope that helps! Going from memory at the moment...

Avatar

Level 2

Jono,

I'm a noobie so thanks for correcting my syntax there. You were a huge help, I'm now using this which seems to be working:

if

(this.Day.rawValue == 0)

{ xfa.host.messageBox("Day is Checked.");

Department.Wastewater.rawValue

= 0;

}

Avatar

Level 10

I don't think you need the fieldname after "this" but it might depend on where you have the script placed, is it on a radio button group or placed on a specific button? If it's on a specific button it would just be "this.rawValue".

Avatar

Level 2

You're correct, it's placed on the group "TimeofCall".

I added an else so that if the other button in Department is checked it will uncheck Wastewater. It's working great, thanks again for your help.

if

(this.Day.rawValue == 0)

{ Department.Wastewater.rawValue

=0;

}

else

     { Department.Wastewater.rawValue

= 1;

}

Avatar

Level 10

Never mind, just tested it out and I see that "this" refers to the radio button group and then the field name selects proper field.