Adding and Removing Fields
Here is my frustrating situation. I have created a code that adds fields to the pages when a radio button is clicked. Here is what I am using:
var Pg1 = this.addField({cName:"Pg1", cFieldType:"text", nPageNum:0, oCoords:[510,77,580,59]}); getField("Pg1").readonly = true; Pg1.value = "Page 1" + " of " + (this.numPages); Pg1.textSize = 10; Pg1.textFont = "TimesNewRoman";
var Pg2 = this.addField({cName:"Pg2", cFieldType:"text", nPageNum:1, oCoords:[510,77,580,59]}); getField("Pg2").readonly = true; Pg2.value = "Page 2" + " of " + (this.numPages); Pg2.textSize = 10; Pg2.textFont = "TimesNewRoman";
//and it continues on with that code for additional pages.
What is happening is that I want these newly added fields (Pg1, Pg2, Pg-etc) to be removed/deleted when a different radio button is selected. I have tried: this.removeField("Pg1"); this.deleteField("Pg1"); doc.removeField("Pg1"); this.resetField("Pg1"); but none of them work. If I use a reset form for all of the fields in the entire document, then some of the added fields will disappear, but Pg1 and Pg5 won't. What is even more annoying is that field Pg1 just keeps being added and cannot be manually removed. In other words, eveytime I use the script, there is a new Pg1 field created in the list of fields, but it cannot be selected and removed (see attached pic). I try to select the field in the list but it's like the field is not actually in the document. Does that make sense? I can go in and manually delete the Pg5 fields, but that's frustrating and the end users of this form will not have that ability.
Anyway, that's my problem. I'm sure I'm just missing something easy, but if someone knows how to get those fields to be removed or deleted, I would be grateful. Thanks for your patience.

