|
技术资料 > ASP技术 > 脚本编码 : 根据选择的Checkbox动态在表格中列出选择的值 |
根据选择的Checkbox动态在表格中列出选择的值 March 25,2004 |
<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.checked)
{
wtfsmc+=vbtrim(form1.wtfs.nextSibling.nodeValue)+",";
chkval[curstr]+=vbtrim(form1.wtfs.value)+",";
form1.wtfs.checked=false;
form1.wtfs.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=# onclick='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>
<td colspan="2" width="100%"> <font class="navPoint">4</font> <b>当前选择的方式:</b><font color=red>成交金额累计</font> <font class="navPoint">4</font> <b>方式名称:</b><font color=blue>sdasd</font></td>
</tr>
<tr>
<td colspan="2" align="left" width="100%">
<hr width="95%" size="1" color="#808080">
</td>
</tr>
<tr>
<td width="2%"></td>
<td width="98%" rowspan="5" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="2" bgcolor="#fffffa">
<tr>
<td width="66%"><fieldset><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="33%">
<input type="checkbox" value="0 " name="wtfs">莫名其妙</td>
<td width="33%">
<input type="checkbox" value="1 " name="wtfs">乱七八糟</td>
<td width="34%">
<input type="checkbox" value="2 " name="wtfs">小键盘</td>
</tr>
<tr>
<td width="33%">
<input type="checkbox" value="3 " name="wtfs">电话号码</td>
<td width="33%">
<input type="checkbox" value="4 " name="wtfs">任我行吗</td>
<td width="34%">
<input type="checkbox" value="5 " name="wtfs">自助快餐</td>
</tr>
<tr>
<td width="33%">
<input type="checkbox" value="6 " name="wtfs">其它委托</td>
<td width="33%">
<input type="checkbox" value="7 " name="wtfs">远程接入</td>
<td width="34%">
<input type="checkbox" value="8 " name="wtfs">黎明天亮</td>
</tr>
<tr>
<td width="33%">
</table></fieldset></td>
<td width="34%" valign=top><fieldset><input type="checkbox" value="0" name="ynlj">按累计交易额计算<br><br> <img border=0 id="Image1" name=Image1 style="cursor:hand" src="http://www.dev-club.com/club/bbs/Images/small_logo2.gif" onclick="javascript:checktable()"><br><table border="0" width="20%" cellspacing="0" cellpadding="0"><tr><td width="100%" height=6></td></tr></table></fieldset></td>
</tr>
<tr>
<td width="100%" colspan="2">
<div align="center">
<center>
<table id=wtab border="1" width="99%" cellspacing="0" bordercolorlight="#336699" bordercolordark="#FFFFFF" cellpadding="1" style="visibility: hidden">
<tr bgcolor=#F9E486>
<td width="10%" align="center">序号</td>
<td width="40%" align="center">委托方式</td>
<td width="30%" align="center">是否按累计交易额计算</td>
<td width="30%" align="center">操作选项</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="2%"></td>
</tr>
<tr>
<td width="2%"></td>
</tr>
<tr>
<td width="2%"></td>
</tr>
<tr>
<td width="2%"></td>
</tr>
<tr>
<td colspan="3" width="100%">
<hr width="98%" size="1" color="#808080">
</td>
</tr>
<tr>
<td width="100%" colspan="3" align=right>
<table border="0" width="80%" cellspacing="0">
<tr>
<td width="34%" align="right"><input class="hand" type="button" value="<< 上一步 " style="border: 1 solid #1D1D1D" onclick="javascript:history.back()"></td>
<td width="23%"><input class="hand" type="submit" value="下一步 >>" style="border: 1 solid #1D1D1D" ></td>
<td width="43%"> <input class="hand" type="button" value="关闭窗口" style=" border: 1 solid #1D1D1D" onclick="javascript:(confirm('真的确定关闭吗?'))?window.close():1==2;"></td>
</tr>
</table><br>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</form>
|
|
Copyright © 2001-2008 Shenzhen Hiblue Software Team All rights reserved