javascript代码:        function ChkPersonal_onclick() {
if ( ChkPersonal.checked )
{
TxtPersonName.style.display = "";
CboOrgan.style.display = "none";
}
else
{
TxtPersonName.style.display = "none";
CboOrgan.style.display = "";
}
}
  Struts标签:  <html:select styleClass="ComboStyle" styleId="CboOrgan" style="WIDTH: 50%" property="infoSourceName">
      <html:options collection="infoSourceList" property="infoSourceName" labelProperty="infoSourceName" />
  </html:select>
  <html:text styleClass="TxtStyle" styleId="TxtPersonName" style="DISPLAY: none; WIDTH: 50%" property="infoSourceName" />&nbsp;
  <INPUT id="ChkPersonal" onclick="return ChkPersonal_onclick()" type="checkbox" name="ChkPersonal">个人发布问题:我想点击"个人发布"后让"html:select"的内容隐藏,但是javascript代码不能执行,请高手帮忙看看那个地方错了!
在线等,谢谢.

解决方案 »

  1.   

    把styleId="CboOrgan" 改为Id="CboOrgan" 试试
      

  2.   

    个人一点偷懒的小建议,能不能不去试图直接操作你的select标签。因为那样通过寻找id的形式定位的确很麻烦。如果可以,尝试在select的外面嵌套一层div层,然后给div层一个id。这样display属性你就直接控制div层,可好?
      

  3.   

    把styleId="CboOrgan" 改为Id="CboOrgan" 后,提示不支持"Id"属性
      

  4.   

    我估计是你的标签用的不对,把标签去掉之后我测试是正常的.<html:select>-><select> 要么就用"shen_long"的办法
      

  5.   

    大致意思:
    <div id="Oo"><html:select styleClass="ComboStyle" styleId="CboOrgan" style="WIDTH: 50%" property="infoSourceName">
    <html:options collection="infoSourceList" property="infoSourceName" labelProperty="infoSourceName" />
    </html:select></div> 然后js改写:
    function ChkPersonal_onclick() {
    if ( ChkPersonal.checked )
    {
    TxtPersonName.style.display = "";
    document.getElementById("Oo").style.display="none";//异或.innerHTML="";
    }
    else
    {
    TxtPersonName.style.display = "none";
    document.getElementById("Oo").style.display=" ";
    }
    }试试看
      

  6.   

    还是一样的错误.说"ChkPersonal"没有被声明.
      

  7.   

    套了div就和ChkPersonal无关了,用id="Oo"
      

  8.   

    ChkPersonal.checked 这个位置你确实需要提前排错的。
    这个写法也不太对啊,哥哥。将ChkPersonal这个控件作为对象获取到,然后再循环排定它的checked属性。另你不一定要用checked属性作为判断依据,也可以写一个钥匙用onchange事件作为判断。
      

  9.   

    你可以试一下,if ( ChkPersonal.selected==checked )
      

  10.   

    用DIV 肯定可以
    我觉得还可以用标签的rendered属性