|
<tr>
<td width="10%"><table width="100%" height="100%" border="1">
<tr>
<td><input type="button" name="Submit3" value="最上" onClick="moveFirst()"></td>
</tr>
<tr>
<td><input type="button" name="Submit" value="向上" onClick="moveUp()"></td>
</tr>
<tr>
<td><input type="button" name="Submit2" value="向下" onClick="moveDown()"></td>
</tr>
<tr>
<td><input type="button" name="Submit4" value="最下" onClick="moveEnd()"></td>
</tr>
</table></td>
<td><table width="100%" border="1" id="DynaTable">
<tr>
<td><input type="radio" name="radio1" value="1" onClick="radioChecked(this)"></td>
<td>第一個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="2" onClick="radioChecked(this)"></td>
<td>第二個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="3" onClick="radioChecked(this)"></td>
<td>第三個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="4" onClick="radioChecked(this)"></td>
<td>第四個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="5" onClick="radioChecked(this)"></td>
<td>第五個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="6" onClick="radioChecked(this)"></td>
<td>第六個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="7" onClick="radioChecked(this)"></td>
<td>第七個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="8" onClick="radioChecked(this)"></td>
<td>第八個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="9" onClick="radioChecked(this)"></td>
<td>第九個</td>
</tr>
<tr>
<td><input type="radio" name="radio1" value="10" onClick="radioChecked(this)"></td>
<td>第十個</td>
</tr>
</table></td>
</tr>
</table>
<script language="Javascript">
<!--
var moveRow=false;
var moveRadio=false;
function radioChecked(obj){
moveRadio=obj;
moveRow=obj.parentNode.parentNode;
}
function moveUp(){
if(moveRow){
var prevRow=moveRow.previousSibling;
if(prevRow){
document.all["DynaTable"].childNodes[0].insertBefore(moveRow,prevRow);
moveRadio.checked=true;
}
}
}
function moveDown(){
if(moveRow){
var nexRow=moveRow.nextSibling;
if(nexRow){
var nnextRow=nexRow.nextSibling;
if(nnextRow){
document.all["DynaTable"].childNodes[0].insertBefore(moveRow,nnextRow);
}else{
document.all["DynaTable"].childNodes[0].appendChild(moveRow);
}
moveRadio.checked=true;
}
}
}
function moveEnd(){
if(moveRow){
document.all["DynaTable"].childNodes[0].appendChild(moveRow);
moveRadio.checked=true;
}
}
function moveFirst(){
if(moveRow){
document.all["DynaTable"].childNodes[0].insertBefore(moveRow,document.all["DynaTable"].childNodes[0].firstChild);
moveRadio.checked=true;
}
}
//-->
</script>
JavaScript技術:動態控制Table的js代碼,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。