• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

initialize a radio button in a dialog box in accordance with a value of a field of the form

Community Expert ,
Feb 27, 2021 Feb 27, 2021

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.

@+

TOPICS
How to , JavaScript , PDF forms

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2021 Feb 27, 2021

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2021 Feb 27, 2021

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).

Capture d’écran 2021-02-27 à 23.29.48.pngCapture d’écran 2021-02-27 à 23.30.13.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

OK, so how are you passing that value to the dialog?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2021 Feb 27, 2021

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

When the radio buttons belongs to a button group set only one button to true.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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.

@+

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

You don't need the "eval" method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

That's exactly what it does...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

It works:

Bild1.jpg

 

Bild2.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Ah, OK! that works fine for both of you...

But for me that doesn't work, hence the misunderstanding!

Capture d’écran 2021-02-28 à 17.31.17.png

Capture d’écran 2021-02-28 à 17.31.43.png

  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

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"!!!!

Capture_d’écran_2021-02-28_à_17_46_13.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Here is a new file with my script simplified a bit.

@+

Capture d’écran 2021-02-28 à 17.58.10.png

Capture d’écran 2021-02-28 à 17.58.31.png

  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

What app does you use? In your pictures I see the Cancel button left of the OK button.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

Acrobat Pro DC Mac.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 28, 2021 Feb 28, 2021

Copy link to clipboard

Copied

LATEST

OK

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines