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

Help with radio buttons

Advisor ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Hello forum!

Can someone help me make a couple of radio buttons functional for odd or even pages to this existing script?

I have separate script to create new pages "BEFORE" doc.pages but I would like to have the two options in one.......not two separate scripts.

I tried to reach the person who originally posted the below script but they haven't been on the forum in months.

Thanks for any help in advance!

//original

var doc = app.documents[0]; 

var masterNames = doc.masterSpreads.everyItem().name; 

var d = app.dialogs.add({name:"pick a master spread"}); 

d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"}); 

var dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames}); 

if(d.show()){ 

     var index = dd.selectedIndex; 

     d.destroy(); 

} else { 

     d.destroy();exit(); 

var master = doc.masterSpreads.item(index); 

for(var i=doc.pages.length-1;i>=0;i--){ 

     doc.pages.add(LocationOptions.AFTER,doc.pages,{appliedMaster:master});

//

var doc = app.documents[0];

var masterNames = doc.masterSpreads.everyItem().name;

var d = app.dialogs.add({name:"Apply Master Page"});

d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});

var dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames});

//added radio buttons

var radioBtns = d.dialogColumns.add().radiobuttonGroups.add();

  radioBtns.radiobuttonControls.add({staticLabel:"Odd Pages",checkedState:true});

  radioBtns.radiobuttonControls.add({staticLabel:"Even Pages"});

     if(d.show()){

     var index = dd.selectedIndex;

     d.destroy();

     } else {

     d.destroy();exit();

}

     var master = doc.masterSpreads.item(index);

     for(var i=doc.pages.length-1;i>=0;i--){

     doc.pages.add(LocationOptions.AFTER,doc.pages,{appliedMaster:master});

     }

TOPICS
Scripting

Views

599

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

correct answers 1 Correct answer

Mentor , Jul 11, 2017 Jul 11, 2017

Hi,

Define a var 'even' to cover selected Button and differ an action:

var

    doc = app.activeDocument,

    masterNames = doc.masterSpreads.everyItem().name,

    d = app.dialogs.add({name:"Apply Master Page"}),

    dd, radioBtns, index, even, master;

  

d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});

dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames, selectedIndex:0});

radioBtns = d.dialogColumns.add().radiobuttonGroups.add();

radioBtns.radiobuttonControls.add({static

...

Votes

Translate

Translate
Mentor ,
Jul 10, 2017 Jul 10, 2017

Copy link to clipboard

Copied

Hi,

Did you consider to modify your masterSpread as predefined two pages  (odd/even)?

Jarek

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
Advisor ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Hi Jarek!

The original script applies the selected master the the even pages or the pages AFTER, so currently running the script on a 10 page document it will give you ten additional pages of the selected master, one AFTER each of the original 10 pages.

Original option is only for the Master pages.

PM.png

I would like to make the added radio buttons functional, giving the option to add the selected master either before or after the existing pages in a document.

PMO.png

Thanks for any help or guidance you may have!

M

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
Mentor ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

Hi,

Define a var 'even' to cover selected Button and differ an action:

var

    doc = app.activeDocument,

    masterNames = doc.masterSpreads.everyItem().name,

    d = app.dialogs.add({name:"Apply Master Page"}),

    dd, radioBtns, index, even, master;

  

d.dialogColumns.add().staticTexts.add({staticLabel:"Master Pages:"});

dd = d.dialogColumns.add().dropdowns.add({stringList:masterNames, selectedIndex:0});

radioBtns = d.dialogColumns.add().radiobuttonGroups.add();

radioBtns.radiobuttonControls.add({staticLabel:"Odd Pages",checkedState:true});

radioBtns.radiobuttonControls.add({staticLabel:"Even Pages"});

if(d.show()){

    index = dd.selectedIndex;

    even = radioBtns.selectedButton;

    d.destroy();

} else {

    d.destroy();

    exit();

}

master = doc.masterSpreads.item(index);

for(var i=doc.pages.length-1;i>=0;i--){

    if (even)

        doc.pages.add(LocationOptions.AFTER,doc.pages,{appliedMaster:master});

    else

        doc.pages.add(LocationOptions.BEFORE,doc.pages,{appliedMaster:master});

    }

Jarek

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
Advisor ,
Jul 11, 2017 Jul 11, 2017

Copy link to clipboard

Copied

LATEST

Thanks Jarek!

I was missing the "even =" and "(even)"  when I was trying to get this to work...........thanks again!

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