0
我有2 checkboxes
,當點擊應該隱藏/取消隱藏divs
。使用div.style.display「塊」:「無」隱藏/取消隱藏基於2複選框
- 在初始頁面加載時,如果
fundingAvailable
=false
上傳應該隱藏。 (見圖像)
- 當用戶點擊
Special Handling
複選框,則上傳應hidden
。 (見圖像)
- 當用戶點擊
Override Funding
複選框,fundingAvailable
=false
,上載應shown
。 (見圖片)
這是我到目前爲止有:
JSP
<INPUT TYPE="CHECKBOX" id="cbOverrideFunding" value="true" onclick="fundingAvailableWarning(<%=fundingAvailable%>)" >
<INPUT TYPE="CHECKBOX" ID="cbSpecialHandling" value="true" onclick="specialHandlingWarning()">
<% if(!fundingAvailable) { %>
<TR>
<TD height="90" valign="top"><BR>
<div id="fundingAvailable" style="display: block">
<b><i>The upload functionality has been disabled because the funding is missing.</i></b>
</div>
<div id="uploadFile">
<INPUT name="File1" type="file" id="File1"/>
<a href="fileUpload()">
<IMG src="../../images/UploadFile.gif" alt="Upload File">
</a>
</div>
<% } %>
<% else { %>
<div id="uploadFile">
<INPUT name="File1" type="file" id="File1"/>
<a href="fileUpload()">
<IMG src="../../images/UploadFile.gif" alt="Upload File">
</a>
</div>
<div id="uploadFileSpecialHandling" style="display: none">
<b><i>The upload functionality has been disabled because of Special Handling.
</i></b>
</div>
<% } %>
的JavaScript
function specialHandlingWarning()
{
if(document.getElementById("fundingAvailable").checked) {
var div = document.getElementById("uploadFile");
div.style.display = div.style.display == "none" ? "block" : "none";
div = document.getElementById("uploadFileSpecialHandling");
div.style.display = div.style.display == "none" ? "block" : "none";
}
}
function fundingAvailableWarning(fundingAvailable)
{
if(!fundingAvailable) {
var div = document.getElementById("uploadFile");
div.style.display = div.style.display == "none" ? "block" : "none";
div = document.getElementById("fundingAvailable");
div.style.display = div.style.display == "none" ? "block" : "none";
}
}
我的問題是,這兩個div在一起玩不好。
如果我先選擇Special Handling
,它將顯示Upload
頁面並隱藏我的警告。
你可以試試'unset'來代替'none'這裏=>'? 「block」:「none」;'? –
@David R你的意思是在uploadFile div或全部? – Angelina