abracadabraPDF › Forums › PDF – Général › Activé / Désactivé (Grisé) un bouton selon la valeur d’un champ › Répondre à : Activé / Désactivé (Grisé) un bouton selon la valeur d’un champ

Salut,
A la base on a :
// Function to enable form fields function
EnableFormField (cFieldName)
{
// First acquire the field to be enabled
var oFld = this.getField(cFieldName)
// Next acquire the hidden field with the normal colors
var oNmlFld = this.getField(“NormalColorsFld”);
if(oFld)
{
// Make field interactive
oFld.readonly = false;
// Restore Normal Colors
oFld.fillColor = oNmlFld.fillColor; oFld.borderColor = oNmlFld.borderColor; oFld.textColor = oNmlFld.textColor;
}
}
// Function to disable form fields function
DisableFormField(cFieldName)
{
// First acquire the field to be disabled
var oFld = this.getField(cFieldName)
if(oFld)
{
// Make field Read-Only
oFld.readonly = true;
// Set Grayed out colors
oFld.fillColor = [“G”, 0.75]; oFld.borderColor = [“G”, 2/3]; oFld.textColor = [“G”, 0.5];
}
}
Que l’on va transformer ainsi :
// Function to manage form fields function
ManageFormField (cFieldName)
{
var seuil = this.getField(“CHAMP-SEUIL”).value;
if (seuil > 70)
{
// First acquire the field to be enabled
var oFld = this.getField(cFieldName)
// Next acquire the hidden field with the normal colors
var oNmlFld = this.getField(“NormalColorsFld”);
if(oFld)
{
// Make field interactive
oFld.readonly = false;
// Restore Normal Colors
oFld.fillColor = oNmlFld.fillColor; oFld.borderColor = oNmlFld.borderColor; oFld.textColor = oNmlFld.textColor;
}
}
else
{
// First acquire the field to be disabled
var oFld = this.getField(cFieldName)
if(oFld)
{
// Make field Read-Only
oFld.readonly = true;
// Set Grayed out colors
oFld.fillColor = [“G”, 0.75]; oFld.borderColor = [“G”, 2/3]; oFld.textColor = [“G”, 0.5];
}
}
}
:Smiley15: