Javascript 根据条件显示DIV

Javascript 根据条件显示DIV,javascript,html,Javascript,Html,我的jsp页面中有以下声明: 其中b3是struts action类中映射的cable实例 <s:set var="b3unit" scope="request" value="b3.cableunit"/> <s:set var="b3sid" scope="request" value="b3.cableid" /> <s:set var="b3tube" scope="request" value="b3.btube"/>

我的jsp页面中有以下声明: 其中b3是struts action类中映射的cable实例

    <s:set var="b3unit" scope="request" value="b3.cableunit"/>
    <s:set var="b3sid" scope="request" value="b3.cableid" />
    <s:set var="b3tube" scope="request" value="b3.btube"/>
    <s:set var="b3fiber" scope="request" value="b3.bfiber"/>
    <s:set var="b3id" scope="request" value="b3.cable_user_id" />
    <s:set var="b3name" scope="request" value="b3.cable_name" />

 <%  String b3 = (String) request.getAttribute("b3sid");
        String b3_type = "Cable";
        String b3_id = (String) request.getAttribute("b3id");
        String b3_name = (String) request.getAttribute("b3name");
        int b3_tube = (Integer) request.getAttribute("b3tube");
        int b3_fiber = (Integer) request.getAttribute("b3fiber");
        float b3_tot_height = b3_tube * b3_fiber * 10.8f;
        float b3_tube_sec_height = b3_tot_height / b3_tube;

和一个动态DIV:

<div  class="type_b" style="margin-left: 1300px; margin-top:-<% out.print((height * 11) + 100);%>px ;  height: <% out.print(height);%>px">
                <div class="section" style="float: right; margin-left: 55px; height: <% out.print(height);%>px">                        
                    <div id="cable_3" class="cable" style="margin-top: <% out.print((b3_tot_height/2)+b_tot_height);%>px"></div>
                </div>

                <div class="section" style="float: right; margin-left: 55px; height: <% out.print(b3_tot_height);%>px">
                    <%

                        for (int y = 1; y <= b3_tube; y++) {%>
                    <div id="b3tube_<%out.print(y);%>" class="tube" style="margin-top: <%


                          if (y == 1) {
                            out.print((b3_tube_sec_height / 2)+b_tot_height+30);
                        } else {
                            out.print((b3_tube_sec_height));
                        }


                         %>px"></div>
                    <% }%>
                </div>
            </div>     

当且仅当b3不为null时,如何显示DIV?任何JSP测试条件

if(b3 != null){
//put type_b div here
}

如果它为true,它将只呈现if语句中的内容,因此如果b3不是null,那么它将显示。如果您有一个包含b3值的变量,那么您可以这样做。您没有提供足够的信息,但根据收集到的信息,这是我的答案。

最好发布HTML,而不是asp模板。您是说整个HTML?