JavaScript - Using variable to set radio button active - Need some help . .

New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

Hello:

 

I have a script such as this:

 

   var dialogComm01 = {
   initialize: function(dialog) {
   dialog.load({"comm":this.strComm});
   dialog.load({"rd1": true});
   this.ServArea = true;
   dialog.enable({
      "rd1" : this.ServArea,
      "rd2" : this.ServArea,
      "rd3" : this.ServArea,

 

The first radio button "rd1" is the default.  I would like to set the default via a variable or global variable instead which might be rd2 or rd3 etc. such as like this:

 

   var dialogComm01 = {
   initialize: function(dialog) {
   dialog.load({"comm":this.strComm});
   dialog.load({global.defSA: true});
   this.ServArea = true;
   dialog.enable({
      "rd1" : this.ServArea,
      "rd2" : this.ServArea,
      "rd3" : this.ServArea,

 

But it does not fly.  Any direction would be greatly appreciated.

 

Thanks;

Nick  

 

TOPICS
Acrobat SDK and JavaScript

Views

42

Likes

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

JavaScript - Using variable to set radio button active - Need some help . .

New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

Hello:

 

I have a script such as this:

 

   var dialogComm01 = {
   initialize: function(dialog) {
   dialog.load({"comm":this.strComm});
   dialog.load({"rd1": true});
   this.ServArea = true;
   dialog.enable({
      "rd1" : this.ServArea,
      "rd2" : this.ServArea,
      "rd3" : this.ServArea,

 

The first radio button "rd1" is the default.  I would like to set the default via a variable or global variable instead which might be rd2 or rd3 etc. such as like this:

 

   var dialogComm01 = {
   initialize: function(dialog) {
   dialog.load({"comm":this.strComm});
   dialog.load({global.defSA: true});
   this.ServArea = true;
   dialog.enable({
      "rd1" : this.ServArea,
      "rd2" : this.ServArea,
      "rd3" : this.ServArea,

 

But it does not fly.  Any direction would be greatly appreciated.

 

Thanks;

Nick  

 

TOPICS
Acrobat SDK and JavaScript

Views

43

Likes

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
Oct 27, 2020 0
Most Valuable Participant ,
Oct 27, 2020

Copy link to clipboard

Copied

To set a field's value you must use the load method, not enable...

Likes

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
Reply
Loading...
Oct 27, 2020 0
New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

This is not actually for a field but for a dialog box called from a document level javascript.  Do I still use the load method ?

 

Thanks;

Nick

Likes

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
Reply
Loading...
Oct 27, 2020 0
Most Valuable Participant ,
Oct 27, 2020

Copy link to clipboard

Copied

I understood that. Yes, you must use the load method, like you did with the "comm" field.

And this line will not work:

dialog.load({global.defSA: true});

If you want to apply a value to a global variable just do it directly, like this:

global.defSA = true;

The load method of the dialog object is only used to populate a field within it with a value.

Likes

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
Reply
Loading...
Oct 27, 2020 0
New Here ,
Oct 27, 2020

Copy link to clipboard

Copied

OK - thanks for the help - I will give it a shot.

 

Nick

Likes

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
Reply
Loading...
Oct 27, 2020 0