Javascript-如果我在第二个jsp页面中包含第一个JSP文件,则不会触发JS方法

时间:2018-07-16 13:29:28

标签: javascript java css jsp styling

问题我想在选中复选框时使元素div可见。 并且当未选中时,div应该是不可见的。 我已经在a.jsp中编写了我的js函数,并且还在其中添加了一个复选框。 我在其他jsp页面中包含a.jsp,但我无法获取 行为符合预期

第一个文件marketingPara.jsp代码

    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<br>
<div class="tracking">
<span class="first">abc Heading</span>
<table id="${username}-" onload="">
</table>
</div>


<div class="checkbox">
    <input type = "checkbox" id = "myCheck" onclick = "funcload()" name=""><span class="heading">(For internal use only)</span>

</div>
<br>
<div id ="marketingPara" style="visibility:hidden;display: none">
<span class="heading">marketingPara</span>
<table id="${username2}-" onload="">
</table>
</div>
<br>
<div id = "passthroughPara" style="visibility:hidden;display: none">
<span class="heading">passthroughPara</span>
<table id="${username3}-">
</table>
</div>
<br>

<script>
    function funcload() {

        var check = document.getElementById("myCheck").checked;

        alert(check);
        if(check){
            document.getElementById("marketingPara").style.display = "block";
            document.getElementById("passthroughPara").style.display = "block"
            document.getElementById("marketingPara").style.visibility = "visible";
            document.getElementById("passthroughPara").style.visibility = "visible";
        }else{
            document.getElementById("marketingPara").style.display = "none";
            document.getElementById("passthroughPara").style.display = "none"
            document.getElementById("marketingPara").style.visibility = "hidden";
            document.getElementById("passthroughPara").style.visibility = "hidden";
        }

    }
    </script>

第二个Jsp文件(Dtype.jsp)

<tab id="C" title="<br>C" icon="c"
          Attributes="onclick:setMainTab('C'),$('#dlink').val('')">
    <tabs id="packsub">
        <tab id="dc" title="D">
            <div class="">
                <jsp:include page="marketingPara.jsp">
                    <jsp:param name="dType" value="dc"/>
                </jsp:include>
            </div>
        <tab>
        <tab id="pL" title="CL">
            <div id="pL-error" class="error"></div>
            <div class="subgroup">pL
            </div>
            <jsp:include page="marketingPara.jsp">
                <jsp:param name="dType" value="pL"/>
                <jsp:param name="marketingPara" value=""></jsp:param>
            </jsp:include>
        </tab>
    </tabs>
</tab>

为什么我在加载该页面时无法在Dtype.jsp中看到div 在marketingpara.jsp页面中该功能是否正常工作

0 个答案:

没有答案