Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bootstrap 4-使用Javascript显示模式_Javascript_Jquery_Bootstrap 4_Bootstrap Modal - Fatal编程技术网

Bootstrap 4-使用Javascript显示模式

Bootstrap 4-使用Javascript显示模式,javascript,jquery,bootstrap-4,bootstrap-modal,Javascript,Jquery,Bootstrap 4,Bootstrap Modal,我有一个按钮,用来打开一个带有Javascript函数的引导模式 <button type="button" class="btn btn-primary" id="myBtn" onclick="return check_PJ();">PJ</button> 我被这个问题困住了,当我点击打开模式的按钮时,不透明度属性“.fade”)仍然是0,所以模式就像是不可见的。。。也许我错过了什么 PS:我使用bootstrap4我没有看到id为ref的元素。check\PJ和c

我有一个按钮,用来打开一个带有Javascript函数的引导模式

<button type="button" class="btn btn-primary" id="myBtn" onclick="return check_PJ();">PJ</button>
我被这个问题困住了,当我点击打开模式的按钮时,不透明度属性“.fade”)仍然是0,所以模式就像是不可见的。。。也许我错过了什么


PS:我使用bootstrap4

我没有看到id为
ref
的元素。check\PJ和check\u Information函数有不同的名称。这样,在点击按钮时,您将永远不会调用检查信息。正确吗?“ref”是我的JSP页面中输入的ID,相信我,他从来都不是空的,所以在我的JS中,我们总是使用“else”条件gaetonom,是的,我的帖子失败了对不起,我编辑了我的第一篇帖子函数是“check_PJ”
<div class="modal fade" id="mediumModal" tabindex="-1" role="dialog" aria-labelledby="mediumModalLabel" aria-hidden="true">
     <div class="modal-dialog modal-lg" role="document">
         <div class="modal-content">
             <div class="modal-header">
                 <h5 class="modal-title" id="mediumModalLabel">Insertion de pièce(s) jointe(s)</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">&times;</span>
                 </button>
             </div>
             <form name="form1" method="post" onsubmit="checkform();" action="./MAJ_pj.jsp">

             <input type="hidden" value="<%=ref%>" name="ref">
                 <div class="modal-body">
                     Body ....
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
                     <button type="submit" class="btn btn-primary">Ajouter</button>
                 </div>
            </form>
         </div>
     </div>
 </div>
function check_PJ()
    {
        var returnValue = true;
        var ref = document.getElementById("ref").value;

        if(ref.trim() === "" || ref.trim() == "")
        {
            returnValue = false;
        }
        else
        {
            $('#mediumModal').modal('show')
        }

        return returnValue;
    }