根据选择的Checkbox动态在表格中列出选择的值
<style>
p,div,body,td,input,checkbox,button{font-size:9pt;}
</style>
<script language="vbScript">
function vbtrim(str)
vbtrim=trim(str)
end function
function vbisnumeric(iVar)
vbisnumeric=not isnumeric(iVar)
end function
</script>
<script language="JavaScript">
<!--
var chkval=new Array();
var curstr =0;
function checktable()
{
if(typeof(form1.wtfs.length)=="undefined") alert('数目不够,无法继续。'); // One Checkbox err
wtab.style.visibility="visible"; // display table
var wtfsmc="";
chkval[curstr]="";
for(i=0;i<form1.wtfs.length;i++)
{
if (form1.wtfs[i].checked)
{
wtfsmc+=vbtrim(form1.wtfs[i].nextSibling.nodeValue)+",";
chkval[curstr]+=vbtrim(form1.wtfs[i].value)+",";
form1.wtfs[i].checked=false;
form1.wtfs[i].disabled=1;
}
}
if (wtfsmc!="")
{ wtfsmc=wtfsmc.substring(0,wtfsmc.length-1)
chkval[curstr]=chkval[curstr].substring(0,chkval[curstr].length-1)
addtr(wtfsmc,curstr);
curstr++;
}
}
function addtr(mc,iIndex)
{
//wtfsmc=obj.nextSibling.nodeValue; // checkbox后面的文字
iRow=wtab.rows.length;
if (iRow==1) // xuhao value
{
xuhao=1
}
else
{
xuhao=parseInt(wtab.rows[iRow-1].cells[0].innerText)+1;
}
if (form1.ynlj.checked) // 是否
{
shifou="<font color=green>是</font>";
}
else
{
shifou="<font color=blue>否</font>";
}
czuo="[ <a href=# οnclick='javascript:deltab("+iIndex+",event.srcElement.parentElement.parentElement.rowIndex)'>删除</a> ]";
myNewRow =wtab.insertRow(); // insert TR row
for (j=0; j <wtab.rows(iRow-1).cells.length; j++)
{
myNewCell = wtab.rows[iRow].insertCell(j) ; // insert TD cecll of TR collection
switch(j)
{
case 0:
wtab.rows[iRow].cells(j).innerHTML = xuhao+" "; wtab.rows[iRow].cells(j).align="right";
break;
case 1:
wtab.rows[iRow].cells(j).innerHTML = " "+mc; wtab.rows[iRow].cells(j).align="left";
break;
case 2:
wtab.rows[iRow].cells(j).innerHTML =" "+ shifou; wtab.rows[iRow].cells(j).align="left";
break;
case 3:
wtab.rows[iRow].cells(j).innerHTML = czuo; wtab.rows[iRow].cells(j).align="center";
wtab.rows[iRow].cells(j).attachEvent ('onmouseover',SetColor_1);
wtab.rows[iRow].cells(j).attachEvent ('onmouseout', SetColor_2);
break;
}
}
}
function deltab(chkid,iIndex)
{
wtab.deleteRow(iIndex);
for(i=0;i<chkval[chkid].length;i++)
{
if(chkval[chkid].substr(i,1)!=",")
{
idx=parseInt(chkval[chkid].substr(i,1));
for(j=0;j<form1.wtfs.length;j++)
{
if (form1.wtfs[j].value==idx)
{
form1.wtfs[j].disabled=0;
}
}
}
}
}
function SetColor_1()
{
var td=event.srcElement;
td.bgColor="#0099FF";
return true;
}
function SetColor_2()
{
var td=event.srcElement;
td.bgColor="";
return true;
}
//-->
</script>
<form name=form1>
<table border="1" width="100%" bordercolorlight="#006699" cellspacing="0" bordercolordark="#FFFFFF">
<tr>
<td width="100%">
<div align="center">
<center>
<table border="0" width="98%" cellspacing="0" cellpadding="2">
<tr>
<td width="100%" colspan="3"></td>
</tr>
<tr>
<td width="107" rowspan="7" bgcolor="#EEEEEE" style="border: 1 solid #D8D8D8"> <br>
</td>