<div class="ldiv">
<input type="image" src="/selectall.gif" onclick="selectAllCheckBox();"/>
<input type="image" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
<input type="image" src="/recycle.gif" onclick="recycle();"/>
<input type="image" src="/fbagain.gif" onclick="reissue();"/>
<input type="image" src="/deleteall.gif" onclick="doDelete();"/>
</div>
想问一问;
   我想做一个判断;符合条件即显示其中几张图片;
   if((a!= null && a.equals("19"))即显示除了<input type="image" src="/recycle.gif" onclick="recycle();"/>的所有图片..当a!=null && a.equals("17")或者("18")时...显示所有图片除了<input type="image" src="/deleteall.gif" onclick="doDelete();"/>
请问我应该怎么做?很急很急...谢谢

解决方案 »

  1.   

    <div class="ldiv">
    <%
     if((a!= null&&a.equals("19")){
    %>
    <input type="image" src="/selectall.gif" onclick="selectAllCheckBox();"/>
    <input type="image" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
    <input type="image" src="/fbagain.gif" onclick="reissue();"/>
    <input type="image" src="/deleteall.gif" onclick="doDelete();"/>
    <%
    }
    if(a!=null&&a.equals("17")||a.equals("18"){
    <input type="image" src="/selectall.gif" onclick="selectAllCheckBox();"/>
    <input type="image" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
    <input type="image" src="/recycle.gif" onclick="recycle();"/>
    <input type="image" src="/fbagain.gif" onclick="reissue();"/>
    }
    %>
    </div>
      

  2.   

    不好意思!上面少一个括弧<div class="ldiv">
    <%
     if((a!= null&&a.equals("19")){
    %>
    <input type="image" src="/selectall.gif" onclick="selectAllCheckBox();"/>
    <input type="image" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
    <input type="image" src="/fbagain.gif" onclick="reissue();"/>
    <input type="image" src="/deleteall.gif" onclick="doDelete();"/>
    <%
    }
    if(a!=null&&a.equals("17")||a.equals("18"){
    %>
    <input type="image" src="/selectall.gif" onclick="selectAllCheckBox();"/>
    <input type="image" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
    <input type="image" src="/recycle.gif" onclick="recycle();"/>
    <input type="image" src="/fbagain.gif" onclick="reissue();"/>
    <%
    }
    %>
    </div>
      

  3.   

    <div class="ldiv" id="_DIV">
    <input type="image" id="_IMG1" alt="_IMG1" src="/selectall.gif" onclick="selectAllCheckBox();"/>
    <input type="image" id="_IMG2" alt="_IMG2" src="/cencleall.gif" onclick="unselectAllCheckBox();"/>
    <input type="image" id="_IMG3" alt="_IMG3" src="/recycle.gif" onclick="recycle();"/>
    <input type="image" id="_IMG4" alt="_IMG4" src="/fbagain.gif" onclick="reissue();"/>
    <input type="image" id="_IMG5" alt="_IMG5" src="/deleteall.gif" onclick="doDelete();"/>
    </div><script type="text/javascript" language="javascript">
    var a = "<%=a%>";
    //var a=17;
    var _DIV=document.getElementById("_DIV");
    function setStyleDisplay(obj,newValue)
    {
    obj.style.display=newValue;
    }
    function hideSomeImg(imgIDs)
    {
    //如果想一次性更新,先把上一层DIV隐藏,等所以下面的组件完成状态变更后再显示.
    //setStyleDisplay(_DIV,"none");
    var dvs = _DIV.childNodes;
    var img;
    for(var i=0;i<dvs.length;i++)
    {
    img = dvs[i];
    if(img.type == "image")
    {
    setStyleDisplay(img,(imgIDs.indexOf(","+img.id+",")!=-1)?'none':'');
    }
    }
    //setStyleDisplay(_DIV,"");
    }
    if(a==19)hideSomeImg(",_IMG3,");
    else if(a==17 || a==18)hideSomeImg(",_IMG5,");
    </script>
      

  4.   

    TO For_suzhen(不懂装懂) 
    你真是不懂装懂,那种重复代码叫好?如果再来个条件呢?是不是再copy一段if..else?再改一下if 中的条件?如果要修改显示的效果呢?你慢慢改吧..
      

  5.   

    TO 楼上的...只有两个条件,没有必要写的那么复杂在真正的开发中,代码优化是一方面,关键还要看开发进度
    如果每一个条件都进行判断,浪费的只是时间,而头头看到的只是界面的一些东西
    而怎么去实现的他不会去关心,我们可以把扩展性强的方法写在持久层..用于统一调用
    而用于作为展示的界面,在MVC模式中,就不允许做逻辑的处理
      

  6.   

    大师说:"没有不变的需求,世上的软件都改动过3次以上,唯一一个只改动过两次的软件的拥有者已经死了,死在去修改需求的路上。"
    to fulong258(【轰隆隆】) 
    写代码写到你这种程度,为你所在的项目组感到悲哀.
      

  7.   

    谢谢各位...真是难得.感谢网络白客及fulong258(【轰隆隆】)
    THANKS