一个链接控制一个表格的显示和隐藏代码如下 :总是不成功,望高人解决
<SCRIPT language=javascript>
function noshow()
{
document.forms[0].text1.value="lzy";
document.forms[0].text2.value="lzy";
if (document.forms[0].table1.style.display=="")
{
document.forms[0].table1.style.display="none";
}
else {
document.forms[0].table1.style.display="";
}
}
</SCRIPT>
<body>
<a href="Javascript:noshow()">添加</a> <form action="" id="form1" name="form1">
<table id="table1" style="display:;" >
<tr> <td> <input type=text name=text2 > </td> </tr>
</table>
<input type=text name=text1>
</form>
</body>
<SCRIPT language=javascript>
function noshow()
{
document.forms[0].text1.value="lzy";
document.forms[0].text2.value="lzy";
if (document.forms[0].table1.style.display=="")
{
document.forms[0].table1.style.display="none";
}
else {
document.forms[0].table1.style.display="";
}
}
</SCRIPT>
<body>
<a href="Javascript:noshow()">添加</a> <form action="" id="form1" name="form1">
<table id="table1" style="display:;" >
<tr> <td> <input type=text name=text2 > </td> </tr>
</table>
<input type=text name=text1>
</form>
</body>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script language="javascript">
function myFun()
{
if(table1.style.display=="block")
{
table1.style.display="none";
}
else
{
table1.style.display="block";
}
}
</script>
</head>
<body>
<table id="table1" width="200" border="1" style="display:block ">
<tr>
<td>aaa</td>
<td>bbb</td>
<td>ccc</td>
</tr>
<tr>
<td>ddd</td>
<td>eee</td>
<td>fff</td>
</tr>
<tr>
<td>ggg</td>
<td>hhh</td>
<td>iii</td>
</tr>
</table>
<input type="button" value="切换" onClick="myFun()"></body>
</html>