236539-1.html (2614B)
1 <html> 2 <head> 3 <script type="text/javascript"> 4 var NumLine = 0 5 6 function maj(IDLine) 7 { 8 9 var newtr = document.createElement("tr") 10 newtr.setAttribute("id","tr"+IDLine) 11 12 13 var newtdselect = document.createElement("td") 14 var newselect = document.createElement("select") 15 newselect.setAttribute("id","HypothRank_"+IDLine) 16 newselect.setAttribute("name","HypothRank_"+IDLine) 17 18 for (i=1;i<=IDLine;i++) 19 { 20 21 var newoption = document.createElement("option") 22 newoption.setAttribute("id",i) 23 newoption.setAttribute("class","classoption1") 24 if (i == IDLine) 25 { 26 newoption.setAttribute("selected","selected") 27 } 28 var newtxt = document.createTextNode(i) 29 newoption.appendChild(newtxt) 30 31 newselect.appendChild(newoption) 32 } 33 34 if (i>2) 35 { 36 for (j=1;j<=i-2;j++) 37 { 38 var newoption = document.createElement("option") 39 newoption.setAttribute("class","classoption1") 40 newoption.setAttribute("id",IDLine) 41 var newtxt = document.createTextNode(i-1) 42 newoption.appendChild(newtxt) 43 document.getElementById("HypothRank_"+j).appendChild(newoption) 44 } 45 } 46 47 newtdselect.appendChild(newselect) 48 newtr.appendChild(newtdselect) 49 50 document.getElementById('letbody').appendChild(newtr) 51 52 NumLine++ 53 } 54 55 56 57 function DeleteLine(IDLine) 58 { 59 for (i=1;i<=NumLine;i++) 60 61 { 62 if (i != IDLine) 63 { 64 noeud = document.getElementById("HypothRank_"+i)[IDLine-1] 65 document.getElementById("HypothRank_"+i).removeChild(noeud) 66 for (j=0;j<=NumLine-2;j++) 67 { 68 noeud = document.getElementById("HypothRank_"+i)[j] 69 70 k=j+1 71 noeud.setAttribute("id",k) 72 73 if (k == NumLine) 74 { 75 noeud.setAttribute("selected","selected") 76 } 77 depart = 0 78 taille = noeud.firstChild.nodeValue.length 79 document.getElementById("HypothRank_"+i)[j].firstChild.replaceData(depart,taille,j+1) 80 } 81 } 82 } 83 84 85 noeud = document.getElementById('tr'+IDLine) 86 document.getElementById('letbody').removeChild(noeud) 87 88 NumLine-- 89 90 for (i=IDLine;i<=NumLine;i++) 91 { 92 k=i+1 93 noeud = document.getElementById("tr"+k) 94 noeud.setAttribute("id","tr"+i) 95 96 noeud = document.getElementById("HypothRank_"+k) 97 noeud.setAttribute("id","HypothRank_"+i) 98 noeud.setAttribute("name","HypothRank_"+i) 99 100 } 101 102 103 } 104 105 </script> 106 </head> 107 108 <body> 109 <form> 110 <table border="1" id="latable"> 111 <thead></thead> 112 <tfoot></tfoot> 113 <tbody id="letbody"></tbody> 114 </table> 115 </form> 116 117 <script> 118 document.body.offsetWidth; 119 maj(NumLine+1); 120 document.body.offsetWidth; 121 maj(NumLine+1); 122 document.body.offsetWidth; 123 maj(NumLine+1); 124 document.body.offsetWidth; 125 DeleteLine(2); 126 document.body.offsetWidth; 127 </script> 128 129 </body> 130 </html>