Radiobutton element Yes - No

lpro87

New Member
Hello,
Help solve the problem.
There are three radio button elements where the answers are Yes or No.
And there is a fourth element of the radio button, where the answer should become Yes, provided that the other three elements with the answer Yes. And if at least one answer is No, then the fourth element should become No.

In JavaScript, I can do it individually for each of the 3 elements.

var rbVal = this.form.formElements.get('Form___element1').getValue();
if (rbVal == '1') {
this.form.formElements.get('Form___element4').update('1');
}
else if (rbVal == '2') {
this.form.formElements.get('Form___element4').update('2');
}
 

Attachments

  • Elements.jpg
    Elements.jpg
    70.5 KB · Views: 25
Last edited:
Regarding the 4th element, is the user allowed to "override" the pre-selection? In other words, if the 4th element ends up being either Yes or No, can the user still change it to No or Yes, respectively?
If not (which would seem to make sense to me), I'd say it'd be much easier to make the 4th a (hidden) calc element...
 
Regarding the 4th element, is the user allowed to "override" the pre-selection? In other words, if the 4th element ends up being either Yes or No, can the user still change it to No or Yes, respectively?
If not (which would seem to make sense to me), I'd say it'd be much easier to make the 4th a (hidden) calc element...

Yes, the user should not change the fourth element.

It can also be done with the Calc element. It will only answer Yes or No
 
Yes, the user should not change the fourth element
Well, then why give him a radio button? As suggested, instead make it a (hidden) calc element where you set the value with a PHP condition depending on 1st-3rd elements?
 
Thank you.

$num1 = '{Form___element1_raw}';
$num2 = '{Form___element1_raw}';
$num3 = '{Form___element1_raw}';

$array = compact("num1", "num2", "num3");
$countValues = array_count_values($array);
if($countValues[1] == count($array)){
echo "yes";
}
else{
echo "no";
}
 
Last edited:
Code:
$num1 = '{Form___element1_raw}';
$num2 = '{Form___element1_raw}';
$num3 = '{Form___element1_raw}';
if ($num1 == '1' && $num2 == '1' && $num3 == '1') {
    return 'Yes';
} else {
    return 'No';
}
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top