日期:2014-05-18  浏览次数:20384 次

用JS隐藏控件
在a.aspx页面中有三个RadioButton(同一组的),分别为R1、R2和R3。
同时有三个Panel,分别为P1、P2和P3.

如果R1为TRUE;则P1显示,其他隐藏;如果R2为TRUE,P2显示,其他隐藏;R3同样。
代码如下:
  function   getShow()
  {
        var   day   =     document.getElementById( "R1 ").checked;
        var   week   =     document.getElementById( "R2 ").checked;
        var   month   =     document.getElementById( "R3 ").checked;

        if(day   ==   true)
{
document.all( "P1 ").style.display     =   "inline ";
document.all( "P2 ").style.display   =   "none ";
document.all( "P3 ").style.display   =   "none ";
}

        if(week   ==   true)
                {
document.all( "P1 ").style.display     =   "none ";
document.all( "P2 ").style.display   =   "block ";
document.all( "P3 ").style.display     =   "inline ";
                }

        if(month   ==   true)
{
document.all( "P1 ").style.display   =   "none ";
document.all( "P2 ").style.display   =   "none ";
document.all( "P3 ").style.display   =   "inline ";
}

总是提示“缺少对象”,这是那里出问题了。。

------解决方案--------------------
学习中..