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

How to give all duplicate checkbox names a unique name?

Enthusiast ,
Dec 23, 2021 Dec 23, 2021

Copy link to clipboard

Copied

I found this article that talks about rename all duplicate field names. 

 

    for (var i=0;i<200;i++)
    {
    try{
    var ts=this.getField("Name1."+i).textSize;
    var tf=this.getField("Name1."+i).textFont;
    var rct=this.getField("Name1."+i).rect;
    var pg=this.getField("Name1."+i).page;
    var f=this.addField("name."+i,"text",pg,rct);
    f.textSize=ts;
    f.textFont=tf;
    }catch(e){break}
    }

this.removeField("Name1");

 

I believed this script is for text box. I need to rename all my duplicate checkbox names. Do I sipmly changed the "text" to "checkbox" for checkbox field instead of text box field? I tried that and it didn't really work. I no longer can click on the checkbox once I ran this script. Any suggestion is much appreciated.

TOPICS
JavaScript

Views

3.8K

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

Community Expert , Jan 07, 2022 Jan 07, 2022

Use this code:

 

for(var i = 0; i< 61; i++){
    if(this.getField("T Neej."+i)!= null){
        var ts=this.getField("T Neej."+i).textSize;
        var tf=this.getField("T Neej."+i).textFont;
        var rct=this.getField("T Neej."+i).rect;
        var pg=this.getField("T Neej."+i).page;
        var f=this.addField("checkBox"+i,"checkbox",pg,rct);

        f.textSize=ts;
        f.textFont="ZapfDingbats";
        this.removeField("T Neej."+i);
    }
}

Votes

Translate

Translate
Community Expert ,
Jan 05, 2022 Jan 05, 2022

Copy link to clipboard

Copied

If they all start with "Name1." then you can do it like this:

this.getField("Name1").getArray().length;

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
Enthusiast ,
Jan 05, 2022 Jan 05, 2022

Copy link to clipboard

Copied

This didn't look right because it only shows 1.

this.getField("Name1").getArray().length;

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 ,
Jan 07, 2022 Jan 07, 2022

Copy link to clipboard

Copied

LATEST

this.getField("Name1").getArray().length;

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