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 43
| 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;
// 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;
//alert('1 : '+arrayRow[index].childNodes[0].firstChild.name+'\n'+document.getElementById('param_services_new_input'+next).name);
var nextInput = document.getElementById('param_services_new_input'+next);
alert(nextInput.name+'\n'+nextInput.value);
nextInput.name = 'param_services_new_input'+current;
nextInput.id = 'param_services_new_input'+current;
alert(nextInput.name+'\n'+nextInput.value);
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[5].firstChild.name = 'param_services_new_timeout'+current;
arrayRow[index].childNodes[6].firstChild.name = 'param_services_new_exp'+current;
//alert('2 : '+arrayRow[index].childNodes[0].firstChild.name+'\n'+document.getElementById('param_services_new_input'+next).name);
}
}
}catch(e){alert('Exception : '+e);} |
Partager