代码如下:
<SCRIPT language="javascript">
function changeselect(sid)
{
  document.formsousuo.std1.background="img\top\2ji.jpg";
  document.formsousuo.std1.background="img\top\2ji.jpg";
  document.formsousuo.std2.background="img\top\2ji.jpg";
  document.formsousuo.std3.background="img\top\2ji.jpg";
  document.formsousuo.std4.background="img\top\2ji.jpg";
  document.formsousuo.std5.background="img\top\2ji.jpg";
  document.formsousuo.std6.background="img\top\2ji.jpg";
  document.formsousuo.std7.background="img\top\2ji.jpg";
  eval("document.formsousuo.std" + sid + ".background=\"img\\top\\2ji_r3_c7.jpg\";");
}
</SCRIPT>
<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="1003" border="0" class="STYLE902">
<TR>
<TD noWrap width="33" background="img\top\2ji_r3_c1.jpg" height="27"></TD>
<TD noWrap align="center" width="30%" background="img\top\2ji.jpg" height="27"></TD>
<TD noWrap align="center" width="62" background="img\top\2ji_r3_c7.jpg" height="27" id="std1" onclick="changeselect(1)">全 网</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std2" onclick="changeselect(2)">服 务</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std3" onclick="changeselect(3)">信 息</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std4" onclick="changeselect(4)">商 户</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std5" onclick="changeselect(5)">美 味</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std6" onclick="changeselect(6)">娱 乐</TD>
<TD noWrap align="center" width="62" background="img\top\2ji.jpg" height="27" id="std7" onclick="changeselect(7)">购 物</TD>
<TD noWrap background="img\top\2ji.jpg" height="27" align="center" width="30%">&nbsp;</TD>
<TD noWrap width="38" background="img\top\2ji12.jpg" height="27"></TD>
</TR>
</TABLE>执行时 为什么总是报“document.formsousuo.std1 为空或不是对象”
到底那里写的有问题  各位请帮我看看  小弟先谢了

解决方案 »

  1.   

    补一句
    form id="formsousuo"
      

  2.   

    eval("document.formsousuo.std" + sid + ".background=\"img\\top\\2ji_r3_c7.jpg\";");
      document.getElementById('std'+sid).style.background='img/top/2ji_r3_c7.jpg';
      

  3.   

    楼上朋友的方法我试过了  还报错  说什么参数不正确
    我现在已经实现了
    document.getElementById("std1").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std2").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std3").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std4").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std5").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std6").style.background  = "url(img\\top\\2ji.jpg)";
    document.getElementById("std7").style.background  = "url(img\\top\\2ji.jpg)";

    whichEl = eval("document.getElementById(\"std"+sid+"\")");
    whichEl.style.background  = "url(img\\top\\2ji_r3_c7.jpg)";