js:控制控件可見不可見
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<TD>第一列</TD>
<TD>第二列</TD>
</TR>
</TABLE>
<HR>
<TABLE id=adv style="DISPLAY: none">
<TR>
<TD>隐藏表格</TD>
<TD>隐藏表格</TD>
<TD>隐藏表格</TD>
</TR>
<TR>
<TD>隐藏表格</TD>
<TD>隐藏表格</TD>
<TD>隐藏表格</TD>
</TR>
</TABLE>
<form name="theForm">
<INPUT TYPE="button" NAME="advshow" id="advance" onclick=showadv(this) value="显示高级用户设置选项">
</form>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var isShow = false;
function showadv(bt){
if (isShow) {
document.getElementById("adv").style.display = "none";
bt.value="显示高级用户设置选项";
isShow = false;
}else{
document.getElementById("adv").style.display = "";
bt.value="关闭高级用户设置选项";
isShow = true;
}
}
//-->
</SCRIPT>
</HTML>
動態生成table並動態控制
stable += "<table border='1'>";
for (int i = 0; i < 3; i++)
{
string btnname = "adv" + i.ToString();
stable += "<tr >";
stable += "<td>question:what your name?<input type='button' name='advshow' onclick='showtd(\"" + btnname + "\")' value='显示問題答案' />";
stable += "</td></tr>";
stable += "<tr>";
stable += "<td><table border='1' id='" + btnname + "' style='display: none'>";
stable += "<tr><td>anser:my name is kitty";
stable += "</td></tr>";
stable += "</table></td>";
stable += "</tr>";
}
stable += "</table>";
<script type="text/javascript">
//var isShow = false;
function showtd(id){
alert("111");
if (document.getElementById(id).style.display == "") {
document.getElementById(id).style.display = "none";
// bt.value="显示問題答案";
// isShow = false;
}else{
document.getElementById(id).style.display = "";
// bt.value="隱藏問題答案";
//isShow = true;
}
}
</script>