Interactive PDF form - How to stop script from resetting on reopen?
I have a script that counts the checked boxes up to a predefined number (lets say 5) and stops users from checking more boxes. But when I close and reopen I can check another 5. Is there a way to prevent this from happening?
//----------------------------Document JavaScript Code ----------------------------
var counter = 0; // Checked counter
//--------Count Checked boxes again when document is closed and re-opened ------------
for (var i =0; i<= 100; i++){
if (getField("chkBox" + i).value == "Yes"){
counter += 1;
}
}
//-------------Validation Function ---------------------------------------------------
function validateCheckBox(name,value){
if (value == "Yes" && counter < this.getField("Quantity_Produits_Finale").value){
counter += 1;
}else if (value == "Off"){
counter -= 1;
}else{
getField(name).value = "Off";
app.alert("Vous ne pouvez pas sélectionner plus de " + this.getField("Quantity_Produits_Finale").value + " produit(s)");
}
}
//-----------------End of Document Javascript------------------------
Action on each checkbox
validateCheckBox(event.target.name,event.target.value);
