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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Tableau</title>
<script type="text/javascript">//<![CDATA[
function createTable(){
// Taille et Tableau définis dans la fonction pour l'exemple
var valeurs=new Array(1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384);
var taille=5;
var table=document.createElement('table');
table.setAttribute('width','20%');
table.setAttribute('border','1');
table.setAttribute('align','center');
table.setAttribute('cellspacing','0');
var tbody=document.createElement('tbody');
var i,tr,td,input;
for(i=0;i<taille;i++){
tr=document.createElement('tr');
td=document.createElement('td');
td.setAttribute('align','center');
input=document.createElement('input');
input.setAttribute('type','hidden');
input.setAttribute('id','IdToto_'+i);
input.setAttribute('name','strToto');
input.setAttribute('value',valeurs[i]);
td.appendChild(input);
tr.appendChild(td);
tbody.appendChild(tr);
}
table.appendChild(tbody);
var elt=document.getElementById('tableau');
while(elt.hasChildNodes())elt.removeChild(elt.lastChild);
elt.appendChild(table);
}
window.onload=function(){
createTable();
}
//]]>
</script>
</head>
<body>
<form action="" method="post">
<div id="tableau">*</div>
</form>
</body>
</html> |
Partager