javascript - Unable to open Modal using JS Function -
i've been fiddling codes last few days. it's old project had modify.
scripts
<script src='http://code.jquery.com/jquery-latest.min.js'></script> <script src="/lib/bootstrap/js/bootstrap.min.js"></script> <link href="/css/styles.css" rel="stylesheet" /> @*<script src="/js/jquery.js"></script> <script src="/js/date.js"></script>*@ <script src="/wijmo/controls/wijmo.min.js" type="text/javascript"></script> <script src="/wijmo/controls/wijmo.input.min.js"></script> <script src="/wijmo/controls/wijmo.grid.min.js" type="text/javascript"></script> <script src="/wijmo/controls/wijmo.chart.min.js"></script> <link href="/wijmo/styles/wijmo.min.css" rel="stylesheet" /> @*<link href="/css/bootstrap.min.css" rel="stylesheet" /> --- s.o.b make things white. big "no, no" *@
modal:
<!-- test modal--> <div class="modal fade" id="testmodal" tabindex="-1" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <!--modal header--> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button> <h4 class="modal-title">modal test</h4> </div> <!--modal body--> <div class="modal-body"> <dl class="dl-horizontal"> <dt>branch code</dt> <dd> <input class="form-control" id="bc" type="text" /> </dd> <dt>branch</dt> <dd> <input class="form-control" id="b" type="text" /> </dd> <dt>company id</dt> <dd> <input class="form-control" id="cid" type="text" /> </dd> </dl> </div> <!--modal footer--> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal" id="testedit" onclick="cmdbrancheditok_onclick()"> ok </button> <button type="button" class="btn btn-danger" data-dismiss="modal" id="testmodalcancel"> cancel </button> </div> </div> </div> </div>
javascript function:
<script> @*test function*@ function openmodal() { $('#testmodal').modal('show'); document.getelementbyid('bc').value = "test"; document.getelementbyid('b').value = "test"; document.getelementbyid('cid').value = "test"; } </script>
trigger(button):
<button style="float:left" id="cmdaddbranch" type="button" class="btn btn-default" onclick="openmodal()">open modal</button>
what missing here?
check console have java script error
typeerror: document.getelementbyid(...) null document.getelementbyid('b').value = "test";
chick id=b" missing " attribute in line
<input class="form-control" id=b" type="text" />
replace
<input class="form-control" id="b" type="text" />
Comments
Post a Comment