Je dois compter le nombre de textarea qui sont affichées à la fin d'un processus.
Si dessous le code pour afficher les textarea.
Code : Tout sélectionner
function TabInter()
{
// Set session variables
// Construction Balise début
$_SESSION['Start']= "[ADC_START]".$_SESSION['Method'].$_SESSION['Service'].$_SESSION['Type']
.$_SESSION['Propri'].$_SESSION['Rdv']
.$_SESSION['Rsdp'].$_SESSION['Regul'].$_SESSION['Comment'];
if(isset ($_SESSION['TabInter'])){
$_SESSION['Complement']= "[COMPLEMENT]";
?>
<label> Intervention(s) réalisée(s) en complément du Ticket Principal.</label>
<?PHP
// Cela génère un entier.
// Représentation héx= adécimal:faire un dechex :
for($ligne=1;$ligne<sizeof($_SESSION['TabInter']);$ligne++)
{
$_SESSION['ValueInter']= $_SESSION['TabInter'][$ligne].$_SESSION['FinChaine'];
$_SESSION['ValueInter']= str_replace(' ','',$_SESSION['ValueInter']);
$_SESSION['ValueInter']= $_SESSION['Start'].$_SESSION['Complement'].$_SESSION['ValueInter'];
$_SESSION['ValueMail']= $_SESSION['Start'].$_SESSION['Complement'].$_SESSION['TabInter'][$ligne].$_SESSION['FinChaine'];
?>
<table align="center">
<tr align="center">
<td>
<form id="form-copier" >
<!-- //champ de saisie de texte -->
<textarea id="<?php print_r('tx-'.$ligne); ?>" cols="80" rows="3"disabled="disabled"><?php print_r($_SESSION['ValueInter']) ?></textarea>
<!-- //Bouton copier -->
<input type="button" class="<?php print_r('bt-'.$ligne) ?>" value="Copier la chaîne du Complément / Regul<?php print_r(' -'.$ligne) ?> à coller dans le 'Champs Work Notes*'de ServiceNow." onclick="this.disabled = 'disabled';this.type='checkbox';this.checked='checked'">
</form>
</td>
</tr>
</table>
<!-- Script bouton -->
<script>
(() => {
const button = document.querySelector('.bt-<?php print_r($ligne) ?>');
button.addEventListener("click", () => {
const elemText = document.getElementById("tx-<?php print_r($ligne); ?>");
// supprimer l'attribut disabled si existe
const disabled = elemText.getAttribute("disabled");
elemText.removeAttribute("disabled");
// selectionne le contenu
elemText.focus();
elemText.select();
// copy
document.execCommand("copy");
// réactive l'attribut disabled si existe
disabled && elemText.setAttribute("disabled", disabled);
// remise focus sur Btn
button.focus();
try {
if (document.execCommand('copy')) {
var alerte = "Champs Work Notes* "
alert('La chaine des Balises a été copié ! \n\r Il suffit de la coller dans le ' + alerte + 'de ServiceNow.');
}
} catch (err) {
alert('Pas possible de copier.');
}
window.getSelection().removeAllRanges();
});
})();
</script>
<?PHP
}
}
}// END Function
?>
Mais je me demande si je ne peux pas aussi récupérer une variable dans chaque textarea ?
Je ne sais pas où commencer.
Merci.