我有一个超链接,应该在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);
}
单击超链接验证函数调用并获得成功后,将出现确认消息,在构造上单击“确定”。但<DIV>
标记未被隐藏,因此进度图像未加载。
答案 0 :(得分:0)
这里的代码有点混乱,所以很难说出问题出在哪里,以及你在这里粘贴的内容是否正是你正在使用的内容。但有一种可能性是它没有正确定位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/以查看此操作。