Copy link to clipboard
Copied
Hi,
I have 2 radio buttons ("Rad0" and "Rad1") in a same group of a dialog box and when I launch it, I would like either one or the other one of both buttons is initialized in "true" in accordance with the value of the value of a form field.
I wrote :
dialog.load({
"Rad0": theValue==0,
"Rad1": theValue!=0,
},
dlgInit);
but that doesn't work.
That works fine if I write :
dialog.load({
"Rad0": theValue==0,
},
dlgInit);
or
dialog.load({
"Rad1": theValue!=0,
},
dlgInit);
but I can't choose!
How can I do?
Thanks in advance.
@+
Copy link to clipboard
Copied
Since they are mutually exclusive setting the value of one of them to true should set the other to false automatically... Is that not happening?
Copy link to clipboard
Copied
That's happening if I set manually one radio button "true" the other one is "false", but I would like automatically set "true" to one or the other one button in accordance with the value of a form field (0 or not 0).
Copy link to clipboard
Copied
OK, so how are you passing that value to the dialog?
Copy link to clipboard
Copied
as indicated above:
var theValue=this.getField("fieldName").value;
before calling the dialog box. Then in the dialog box if I write :
dialog.load({
"Rad0": theValue==0,
},
dlgInit);
or
dialog.load({
"Rad1": theValue!=0,
},
dlgInit);
the correct button is set to "true", but I don't know how set automatically the correct button.
dialog.load({
"Rad0": theValue==0,
"Rad1": theValue!=0,
},
dlgInit);
doesn't work...
Copy link to clipboard
Copied
Defining a variable outside the dialog does not make it visible inside of it.
You have to pass it as a property of the dialog object itself, or define it as a global variable.
Copy link to clipboard
Copied
When the radio buttons belongs to a button group set only one button to true.
Copy link to clipboard
Copied
Thanks for your answers.
I found a solution after a good sleeping night!
I use the "eval" method:
I build a string in accordance of the value of the field before calling the dialog box, then I "eval" this string in the "initialize" part of the dialog box.
I load an example if that can help somebody.
@+
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thank you Bernd, but this is not what I needed!
I wished the button Yes ticked if the value of the field is 0 or the button No ticket if the field is not 0.
Your answer is: Yes ticked if the value of the field is 0 but any buttun ticked if the field is not 0.
Copy link to clipboard
Copied
There are only two buttons in the group, though... What do you mean by "any button ticked"? The only other button is No. I think Bernd's example does exactly what you described.
Copy link to clipboard
Copied
I can see this:
Yes button is ticked if the value of the field is 0 and No buttun is ticked if the field is not 0.
Copy link to clipboard
Copied
Maybe I didn't describe correctly what I needed because of my English, but what I wished is the file I posted this morning: the "Yes" button ticked if the field is 0 and the "No" button ticked if the field is not 0 (else that was too easy :-)... it's a joke of course).
Thanks
Copy link to clipboard
Copied
That's exactly what it does...
Copy link to clipboard
Copied
It works:
Copy link to clipboard
Copied
Ah, OK! that works fine for both of you...
But for me that doesn't work, hence the misunderstanding!
Copy link to clipboard
Copied
And in fact I already tested this script yesterday, but I don't understand how it can work fine for you as you only set Rad1 "true" if theValue==0... but you never set Rad2 "true"!!!!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What app does you use? In your pictures I see the Cancel button left of the OK button.
Copy link to clipboard
Copied
Acrobat Pro DC Mac.
Copy link to clipboard
Copied
OK