有谁知道吗??javascript与asp.net如何获取表单动态元素!

fangxianghua9801 2007-05-02 01:29:47
<form name="Form1" method="post" action="ProdIndex.aspx?Typeid=2&ProdTypeId=38" id="Form1">
<table cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
<tr>
<td vAlign="top" width="190">
<script language="javascript">
//div的显示和隐藏
function showHideBlock(obj,block)

{
if (block.length==null)
{
if (block.style.display == 'none')
{
block.style.display = '';
obj.src = '/images/_.gif';
}else
{
block.style.display = 'none';
obj.src = '/images/+.gif';
}
}
else
{
for(i=0;i<block.length;i++)
{
if (block[i].style.display == 'none')
{
alert('c');
block[i].style.display = '';
obj.src = '/images/_.gif';
}
else
{
alert('d');
block[i].style.display = 'none';
obj.src = '/images/+.gif';
}
}
}
}
</script>
<TABLE id="Table8" cellSpacing="0" cellPadding="0" width="180" border="0">
<TR>
<TD> <TABLE id="Table9" cellSpacing="0" cellPadding="0" width="180" align="left" border="0">
<TR>
<TD><IMG height="56" alt="" src="/images/left_pdulist_01.gif" width="180"></TD>
</TR>
<TR>
<TD vAlign="top" width="180" background="/images/left_pdulist_02.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="35" align="right">
<a href='###' onclick='showHideBlock(imguserBlock38,userBlock38)'><img src="/images/+.gif" border="0" id="imguserBlock38"></a></td>
<td height="24"><strong><font color=red> 1 </font></strong><a class="title" href="/Product/ProdIndex.aspx?Typeid=2&ProdTypeId=38"><strong><font color="#653000">淋浴房</font></strong></a></td>
</tr>
<tr>
<td></td>
<td><div id="div38">
<table id='userBlock38' style='DISPLAY:none'>
<tr>
<td> </td>
<td valign="bottom">1.1 <a href="/Product/ProdIndex.aspx?Typeid=3&ProdTypeId=180"><font color="#CC6600">淋浴盆</font></a></td>
</tr>
<tr>
<td> </td>
<td valign="bottom">1.2 <a href="/Product/ProdIndex.aspx?Typeid=3&ProdTypeId=181"><font color="#CC6600">淋浴屏</font></a></td>
</tr>
<tr>
<td> </td>
<td valign="bottom">1.3 <a href="/Product/ProdIndex.aspx?Typeid=3&ProdTypeId=214"><font color="#CC6600">淋浴柱</font></a></td>
</tr>
</table>
</div></td>
</tr>
</table>
<script>showHideBlock(imguserBlock38,userBlock38);</script></TD>
</TR>
<TR>
<TD><IMG height="14" alt="" src="/images/left_pdulist_03.gif" width="180"></TD>
</TR>
</TABLE></TD>
</TR>
</TABLE>
<table id="Table4" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td height="7"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
哪位兄台帮我看看!咋回事呀,去掉form标签后不会报‘imguserBlock38’未定义的错误!一加就会,但是页面需要form提交!求助
...全文
308 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fangxianghua9801 2007-05-02
  • 打赏
  • 举报
回复
谁来接分呀,我自己换了一种方式!!!
fangxianghua9801 2007-05-02
  • 打赏
  • 举报
回复
咋没人回复呀
fangxianghua9801 2007-05-02
  • 打赏
  • 举报
回复
就是说去掉form标签后,运行页面能找到imguserBlock38变量,二级菜单功能能正常实现

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧