[英]show/hide the <div> tag is not working
我有一個超鏈接,它應該在 onclick 事件期間一一調用 3 個 JS 函數。
<form name = "bulkcontactfrm" method="POST" action="<%= servletPath %>>
<div id="saveDiv" layoutAlign="top" style="display:block;">
<table id="" align="left" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="javascript:void(0);" onclick="isAllowedToResubscribe(document.bulkcontactfrm); manipulateDIV(document.bulkcontactfrm); resubscribeCall(document.bulkcontactfrm);"> Re-Subscribe</zoniac:roundrect> </a>
</td>
</tr>
</table>
</div>
<div id="loadingDiv" class="cellWhiteBGFont" layoutAlign="top" style="display: block;"><p><img src="<%=ImageMappingManager.getImageName("imgLoading")%>" name = "b1"> <font size='3'><b>Please wait...<b></font></p>
</div>
</form>
JS函數如下:
// First function validate the data using ajax call
function isAllowedToResubscribe(form) {
//Client validation takes here
processAjaxRequestPost('ajaxRequestPost','SimpleHandler','getResubscribeEmailValidationDetails',emilIDStr,sourcefromStr);
}
// Second function hide the content in UI and show the Processing image in <DIV> tag
function manipulateDIV(form) {
hideSaveDiv();
showLoadingDiv();
}
function hideSaveDiv() {
//hide the Re-Subscribe hyperlink
document.getElementById('saveDiv').style.display='none';
}
function showLoadingDiv() {
//show the Processing image
document.getElementById('loadingDiv').style.display='block';
}
// Third function is for form submit using ajax call
function resubscribeCall(form) {
//processAjaxRequestPost('ajaxRequestPost','SimpleHandler','getResubscribeEmailDetails',emilIDStr,sourcefromStr);
}
單擊超鏈接驗證 function 調用並獲取成功后,出現構造消息,單擊構造上的確定。 但是<DIV>
標簽並沒有被隱藏,所以沒有加載進度圖像。
這里的代碼有點亂,所以很難判斷問題出在哪里,以及你在這里粘貼的內容是否正是你正在使用的。 但一種可能性是它沒有正確定位 div,因為您在form
標記中缺少"
標記:
<form name = "bulkcontactfrm" method="POST" action="<%= servletPath %>>
應該:
<form name="bulkcontactfrm" method="POST" action="<%= servletPath %>">
快速測試似乎表明缺少的"
足以使 DOM 混亂以使document.getElementById()
無法正常工作。比較http://jsfiddle.net/nrabinowitz/n9S33/2/和http://jsfiddle.net/nrabinowitz /n9S33/3/看看這個在行動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.