Remove fileicon (Paperclip) When Required Field value 0
I'm using the following code to upload the file in the PDF Fillable Form
Current Functionality:
When the User hits the file upload button and uploads the file the value of a field increases by 1 and a file icon created (paperclip icon). on second file upload the value increase 1+ and second paper clip created for that file.
When Using Clear Button the file counting field clear to 0 but uploaded files (paperclips icons) still there.
I want to remove the uploaded files icons (paperclips icons) also removed when User Hit the Clear button the Value of the field 0 and all uploaded files removed.
Screenshot File Uploaded:

Screenshot After Clearing the field using Clear Button:
As you see the field clear to 0 but fileuploaded icon still there in second screenshot.
Kindly Update my Following Code to help me.
var nbComptePJ = this.getField("compteurPJ").value;
if ( nbComptePJ <= "5")
{
if ( nbComptePJ == "0") {position = [480,119];}
else if ( nbComptePJ == "1") {position = [500,119];}
else if ( nbComptePJ == "2") {position = [520,119];}
else if ( nbComptePJ == "3") {position = [540,119];}
else if ( nbComptePJ == "4") {position = [560,119];}
else if ( nbComptePJ == "5") {position = [580,119];}
var annot = this.addAnnot({
page: this.pageNum,
type: "FileAttachment",
author: "Qamar Farooq",
contents: "Double Click to check the attachment",
attachIcon: "Paperclip",
point: position,
strokeColor: color.black,
});
nbComptePJ++;
this.getField("compteurPJ").value = nbComptePJ;
}
else
{
alertPJ = "The maximum limit of 5 attachments."
app.alert({cMsg: alertPJ, cTitle: "Titre", nIcon: 3});
}
