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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
<script type="text/javascript">
function enPlus(ad,id)
{
//var id = tableau;
var l = id.insertRow(ad);
for (var c=0;c<id.rows(0).cells.length;c++)
{
var d = c+1;
l.insertCell(l.cells.length).innerHTML=
"<textarea name='tableau"+id+"cellule"+d+"ligne"+ad+"' cols='15' rows='3'>"+" val "+"col"+d+"ligne"+ad+"</textarea>";
}
id.rows[ad].setAttribute("onclick",function(){LigneChoix(this);});
}
function Ajout(id)
{
enPlus(Number(adr.value)+1,id);
}
function Supp(id)
{
if (adr.value!=1)
{
id.deleteRow(Number(adr.value));
adr.value="";
}
}
function LigneChoix(lig)
{
adr.value=lig.rowIndex;
}
function Recup_data(id)
{
var html="";
//boucle sur le nombre de cellules
for (var c=0;c<id.cells.length-2;c++)
{
var b = id.cells(c).innerHTML;
html+=b;
}
//mettre dans une autre fonction l'écriture du code html
document.write(html);
}
function initialisation_tableau(id)
{
for (var l=1;l<2;l++) { enPlus(l,id); }
}
</script>
</HEAD>
<BODY><b>
<!--Début du tableau externe-->
<table border ="1" id="tableau_externe" name="tableau_externe" >
<th colspan="3">Tableau1</th>
<tr>
<td>Nom du tableau : <input type="text" value="Nom du tableau"></td>
</tr>
<tr>
<td align="center">Nom des colonnnes</td>
</tr>
<tr>
<td><!--Début du tableau interne-->
<table id="tableau" name="tableau" border="4">
<tr>
<td><input type="text" value="Colonne numéro 1"></td>
<td><input type="text" value="Colonne numéro 2"></td>
<td><input type="text" value="Colonne numéro 3"></td>
</tr>
<input type="hidden" size=3 name="adr">
<tr>
<td><input type="button" value="Ajouter" onclick="Ajout(tableau);"></td>
<td><input type="button" value="Détruire" onclick="Supp(tableau);"></td>
<!--<td><input type="button" value="Récupérer les données" onclick="Recup_data(tableau);"></td><br>-->
<script>initialisation_tableau(tableau);</script>
</table>
<!--Fin du tableau interne-->
</td><!--Suite du tableau externe-->
</tr>
<tr>
<td><input type="button" value="Ajouter un tableau" onclick="">
<input type="button" value="Détruire un tableau" onclick=""></td>
</tr>
</table><p><hr>
<!--Fin du tableau externe-->
<!------------------------------------------------------------------------------------>
<center><input type="button" value="Récupérer les données" onclick="Recup_data(tableau);"> |