These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to delete a text field?

ThomasJ
Registered: Feb 3 2010
Posts: 2
Answered

Hi,

I'm totally new to Javascript so this might be an easy question.
I have a script that inserts a text field with a barcode in the upper right corner of the first page on every pdf-file. If I run the script multiple times it just add a new text field on top of the existing one. I want the script to remove any existing fields and insert a new one leaving the file with only one (the last inserted) text field. Can anyone please tell me how to do this?

Here's my script:
/* Insert Barcode */
var aPage = this.getPageBox();
aPage[3] = aPage[1] - 50;
aPage[0] = aPage[2] - 1000;
var f = this.addField("myText", "text", 0, aPage);
var FN = documentFileName;
f.delay = true;
f.readonly = true;
f.alignment = "right";
// f.textFont = "Arial";// a barcode font is required here
f.textFont = "Code39-WideTT-Regular";// a barcode font is required here
f.textSize = 60;
f.fillColor = color.transparent;
f.value = "*" + FN.substring(0,FN.length-4) + "*";
f.delay = false;

Regards
ThomasJ

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
this.removeField("myText");

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

debrah.h48
Registered: Feb 5 2010
Posts: 2
txtUserNo.addCommand(cmdDelete);
txtPassword.addCommand(cmdDelete);
txtRcvdNo.addCommand(cmdDelete);
txtAmount.addCommand(cmdDelete);

public void commandAction(Command c, Item i){
if (c== cmdDelete){
var tmp = ((TextField)i).getString();
tmp = tmp.substring(0, tmp.length-1);
((TextField)i).setString(tmp);
}
}