Skip to main content
aj7667
Participating Frequently
April 20, 2017
Answered

How to delete all duplicate buttons from the document?

  • April 20, 2017
  • 2 replies
  • 5427 views

I am facing this problem regularly. I copy a button from other document and paste it in a new document. But sometimes the action for the buttons redirects me to a different location. Then If I select "Select All" and press delete. The hyperlinks and other references in the document get deleted as well. Is there any other method where I can just delete all the buttons.

This topic has been closed for replies.
Correct answer try67

This code will delete all the button fields in your file:

for (var i=this.numFields-1; i>=0; i--) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") this.removeField(f.name);

}

2 replies

Participant
June 5, 2024

This post is over 7 years old but I just helped me out.

Thanks try67. Appreciate the javascript.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 20, 2017

This code will delete all the button fields in your file:

for (var i=this.numFields-1; i>=0; i--) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") this.removeField(f.name);

}

aj7667
aj7667Author
Participating Frequently
April 26, 2017

Hello try67. Thank you for the code. But inspite of multiple attempts, i was facing an error.

I tried this.removeField ("button name"); and it worked fine.

try67
Community Expert
Community Expert
April 26, 2017

What error?