Fonction javascript ajout ligne besoin d'aide

Fermé
roy mustang Messages postés 110 Date d'inscription mardi 24 février 2009 Statut Membre Dernière intervention 2 juin 2009 - 30 mars 2009 à 17:14
Bonjour,
j'ai une fonction qui consiste dans l'ajout de ligne à chaque appuie sur le bouton (ce qui est mis en gras) j'admets que c'est du copie coller et j'ai aucune idée à quoi doit amener ce code j'ai besoin d'aide parce que c'est seulement l'entête qui apparait (ce qui souligné) sans que ça marche :(

<input name="ajout-dim" type="button" onclick="AddRow()" value="donner dimension" />
</p>

<table width="846" border="1" id="table">
<tr>
<td width="237" scope="col">longueur de la carcasse </td>
<td width="192" scope="col">largeur de la carcasse </td>
<td width="214" scope="col">hauteur de la carcasse </td>
<td width="175" scope="col">profondeur de la carcasse </td>
</tr>
</table>

<tr>
<script language="javascript">
function AddRow(){
numero++;
// Titre
var newRow = document.getElementById('table').insertRow(-1);
//
var newCell = newRow.insertCell(0);
newCell.align = 'center';
newCell.innerHTML ='<input type="text" name="long_art"['+numero+']" id="long_art"['+numero+']">';
//
var newCell = newRow.insertCell(1);
newCell.align = 'center';
newCell.innerHTML ='<input type="text" name="larg_art"['+numero+']" id="larg_art"['+numero+']">';
//
var newCell = newRow.insertCell(2);
newCell.align = 'center';
newCell.innerHTML = '<input type="text" name="haut_art"['+numero+']" id="haut_art"['+numero+']">';
//
var newCell = newRow.insertCell(3);
newCell.align = 'center';
newCell.innerHTML ='<input type="text" name="prof_art"['+numero+']" id="prof_art"['+numero+']">';
var newCell = newRow.insertCell(4);
newCell.align = 'center';
newCell.innerHTML = '<input type="button" onclick="deleteCurrentRow(this)" value=" Supprimer" alt="Delete" >';
}
//fonction qui permet d'éffacer des lignes
function deleteCurrentRow(obj)
{
var delRow = obj.parentNode.parentNode;
var tbl = delRow.parentNode;

if(tbl.getElementsByTagName('tr').length==1){
alert('Vous ne pouvez pas supprimer cette ligne');return false ;
}
tbl.removeChild(delRow);
}
</script>
<p> </p>
<p> </p>
<blockquote><input name="btaj" type="submit" value="envoyer" ></blockquote>
merci!!!
A voir également: