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
Solved! Go to Solution.
Views
Replies
Total Likes
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...
Views
Replies
Total Likes
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...
Views
Replies
Total Likes
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;
}
Views
Replies
Total Likes
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".
Views
Replies
Total Likes
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;
}
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Likes
Replies