Supprimer une ligne d'un tableau
Bonjour,
Je sais que ce sujet est déjà traité mais là c'est particulier.
Je souhaite supprimer une ligne que je viens de créer à l'aide d'une fonction d'ajout en Javascript. J'ai bien tenté plusieurs manière et même essayer des solutions proposées que j'ai adapté mais rien à faire :oops:
Voici mon code JavaScript :
Code:
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
| function insRow()
{
var x=document.getElementById('myTable').insertRow(0);
var a=x.insertCell(0);
var b=x.insertCell(1);
var c=x.insertCell(2);
var d=x.insertCell(3);
var e=x.insertCell(4);
var f=x.insertCell(5);
var g=x.insertCell(6);
a.innerHTML="Type : ";
b.innerHTML="<select id='MySel' name='type' style='top:0;left:0;width:150px;'>" +
" <option value=' '>-selectionnez-</option>" +
" <option value='carton'>carton</option>" +
" </select>";
c.innerHTML="Entre les pages ";
d.innerHTML="<input type='text' value='1' name='firstInter' size='1' maxlength='3'/>";
e.innerHTML=" et ";
f.innerHTML='<input type="text" value="1" name="finalInter" size="1" maxlength="3"/>';
g.innerHTML='<a href="#" onClick="suppLigne()"> Supprimer </a>';
}
function supprLigne(){
} |
et voici mon morceau de ma page php:
Code:
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
| <table id="myTable">
<tr>
<td>
Type :
</td>
<td>
<select id="MySel" name="type" style='top:0;left:0;width:150px;'>
<option value=" ">-selectionnez-</option>
<option value="carton">en carton</option>
</select>
</td>
<td>
Entre les pages
</td>
<td>
<input type="text" value="1" name="firstInter" size="1" maxlength="3"/>
</td>
<td>
et
</td>
<td>
<input type="text" value="1" name="finalInter" size="1" maxlength="3"/>
</td>
<td>
<a href="#" onClick="suppLigne()"> Supprimer </a>
</td>
</tr>
</table>
<input type="button" onclick="insRow()" value="Ajouter"> |
Merci d'avance pour votre aide