Javascript Variable to Bootstrap Modal

前端 未结 4 892
误落风尘
误落风尘 2020-12-11 23:53

Got what is probably a simple one, but my google is failing me at the moment so hoping i can get a bit of a push in the right direction

I have a HTML page that is ba

4条回答
  •  心在旅途
    2020-12-12 00:32

    Take a look at the documentation. I believe what you are going to want to do is add a data-toggle="modal" attribute to your calculate button and then make it so when it calls your calculate function, it changes the content in the modal via Javascript.

    The modal is just normal HTML and you can assign ids to whatever you want. From there you can edit it with innerHTML

    
    Calculate
    
    
    
    

    Javascript

    function calculate() {
        //do some calculation and store it in a variable
        var a = b + c; 
        document.getElementById("myModalLabel").innerHTML = "The final calculation is" + a;
    }
    

    Hope I understood your question.

提交回复
热议问题