我正在使用Bootstrap网站。我有文字区域,当你点击" Post"它应该显示一个模型,其中包含您传入的元素。它们中的大多数似乎都在工作,但我遇到以下问题:
我正在使用JavaScript更新它们,在按钮点击时调用showPreview()
函数。
以下是模态的代码:
<div class="modal fade" id="previewModal" tabindex="-1" role="dialog" aria-labelledby="previewModalTitle" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="previewModalTitle">Your Newstream Preview</h4>
</div>
<div class="modal-body">
<h3 id="previewNewstreamTitle"></h3>
<h3 id="previewJournalistName"></h3>
<h4 id="previewNewstreamDate"></h4>
<p id="previewNewstreamSummary"></p>
<h3 id="previewDispatchTitle">f</h3>
<p id="previewDispatch">f</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Publish Newstream</button>
</div>
</div>
</div>
</div>
以下是日期和价格框的代码:
var newstreamTitle = document.getElementById("newstreamTitleBox").value;
document.getElementById("previewNewstreamTitle").innerHTML = newstreamTitle;
var newstreamSummary = document.getElementById("addNewstreamSummaryBox").value;
document.getElementById("previewNewstreamSummary").innerHTML = newstreamSummary;
var author = document.getElementById("journoNameBox");
document.getElementById("previewJournalistName").innerHTML = author;
var date = document.getElementById("articleDateBox").value;
document.getElementById("previewNewstreamDate").innterHTML = date;
var price = document.getElementById("articlePriceBox").value;
document.getElementById("previewArticlePrice").innerHTML = price;
var dispatchTitle = document.getElementById("dispatchTitleBox").value;
document.getElementById("previewDispatchTitle").innerHTML = dispatchTitle;
var dispatch = document.getElementById("addDispatchBox").value;
document.getElementById("previewDispatch").innerHTML = dispatch;
$('#previewModal').modal('toggle');
最后,这是用于更新模态体的JS:
var newstreamTitle = document.getElementById("newstreamTitleBox").value;
document.getElementById("previewNewstreamTitle").innerHTML = newstreamTitle;
var newstreamSummary = document.getElementById("addNewstreamSummaryBox").value;
document.getElementById("previewNewstreamSummary").innerHTML = newstreamSummary;
var author = document.getElementById("journoNameBox");
document.getElementById("previewJournalistName").innerHTML = author;
var date = document.getElementById("articleDateBox").value;
document.getElementById("previewNewstreamDate").innterHTML = date;
var price = document.getElementById("articlePriceBox").value;
document.getElementById("previewArticlePrice").innerHTML = price;
var dispatchTitle = document.getElementById("dispatchTitleBox").value;
document.getElementById("previewDispatchTitle").innerHTML = dispatchTitle;
var dispatch = document.getElementById("addDispatchBox").value;
document.getElementById("previewDispatch").innerHTML = dispatch;
$('#previewModal').modal('toggle');