1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| removeAdd : function(row) {
try{
document.getElementById('param_services_nb_add_param').value = --this.nbAddParam;
var index = row.rowIndex;
// Supression de la ligne passé en paramètre
row.parentNode.removeChild(row);
// Suppresion du textarea de l'input correspondant.
var current = index-this.nbParam;
var inputToDelete = document.getElementById('param_services_new_input'+current);
inputToDelete.parentNode.removeChild(inputToDelete);
// Une fois la ligne supprimé on ré-index le nom des champs suivants pour faciliter l'affichage
// et l'utilisation plus tard, pour permettre une simple boucle.
if (index !== this.table.rows.length) {
var arrayRow = this.table.rows;
var imax = arrayRow.length;
//var parentDiv = document.getElementById('param_services_div_input');
// Ré-indexation de -1 des cas de tests ajoutés suivant celui supprimé.
for (index; index < imax; index++) {
var current = index-this.nbParam;
var next = current+1;
if (index !== imax-1) {
arrayRow[index].childNodes[0].firstChild.name = 'param_services_new_name'+current;
arrayRow[index].childNodes[1].firstChild.name = 'param_services_new_environment'+current;
arrayRow[index].childNodes[2].firstChild.name = 'param_services_new_service'+current;
arrayRow[index].childNodes[3].firstChild.name = 'param_services_new_method'+current;
arrayRow[index].childNodes[3].firstChild.id = 'param_services_new_method'+current;
//arrayRow[index].childNodes[4].firstChild.id = 'param_services_new_display'+current;
arrayRow[index].childNodes[5].firstChild.name = 'param_services_new_timeout'+current;
arrayRow[index].childNodes[6].firstChild.name = 'param_services_new_exp'+current;
document.getElementById('param_services_new_input'+next).name = 'param_services_new_input'+current;
}
}
}
}catch(e){alert('Exception : '+e);}
}, |
Partager