jquery - Javascript Variable to Bootstrap Modal -
got simple one, google failing me @ moment hoping can bit of push in right direction
i have html page bunch of checkboxes. these checkboxes simple self evaluation yes/no questionnaire weighted different values based on questions.
at end of questionnaire, hit calculate results , used quick javascript function calculate score , alert popup give score
i migrated page bootstrap 3 , cleaned bit want use modal popup instead of old style javascript alert
is there simple way of passing javascript calculated variable main page bootstrap modal
thanks
edit
right - worked out, calling jquery code
$('#myresults').html(counter);
from within model - moved snippet main javascript function , works. knew going simple one.. might time stop working think
thanks
yes . can pass variable bootstrap modal.
script file
<script> function testfun(variable){ document.getelementbyid('testh1').innerhtml=variable; } </script>
html
<button class="btn btn-primary btn-lg" onclick="testfun('testid')" data-toggle="modal" data-target="#mymodal"> launch demo modal </button> <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="mymodallabel">modal title</h4> </div> <div class="modal-body"> <h1 id="testh1"></h1> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> <button type="button" class="btn btn-primary">save changes</button> </div> </div> </div> </div>
Comments
Post a Comment