我已經使用複選框來檢查我的郵件系統中用Java開發的郵件。如何自動檢查同名的所有複選框?
我想檢查點擊上方複選框上的所有複選框,但問題是,根據檢索到的郵件數量,複選框顯示在循環中。
請幫我在哪裏應該把JavaScript代碼解決這個問題。
收件箱中的循環代碼如下:
<tr >
<% for(int i=0;i<messageList.size();i++) { message = (Message)messageList.get(i);%>
<td width="10%" height="33" align="left" valign="top" bgcolor="#EEE" >
<!--This link display the full message-->
<input name="Mark_Mail" id="mark_mail" onclick="myfunction(this);" type="checkbox" value="<%=message.getMailId()%>" width="50" height="30" align="top" >
<span id="space1" style="padding:2px"></span>
<!--Check all the Checkboxes-->
<script type="text/javascript">
function checkAll()
{
document.getElementById('mark_mail').checked = "true";
}
</script>
<img src="Images/UnStarred.jpg" height="15" border="0" id="image1" onclick="swapImage()" />
<span id="space1" style="padding:2px"></span>
</td>
<td width="90%" height="33" align="left" colspan="7" valign="bottom" bgcolor="#EEE" >
<!--This link display the full message-->
<a id="link" href="viewMail.jsp?mailId=<%=message.getMailId()%>&isAttach=<%=message.getAttachmentFlag()%>">
<!--Display Sender Address-->
<font color="#000000" size="1"><strong><%=message.getSenderAddress()%></strong></font>
<span id="space1" style="padding:6px"></span>
<!--For Display Message Subject-->
<font color="#000000" size="1"><strong><%=message.getSubject()%></strong></font>
<span id="space1" style="padding:6px"></span>
<!--For Display Attachment Image-->
<%if(message.getAttachmentFlag().equals("1")){%><input type="hidden" name="filename" id="filename" value="<%=message.getFileName()%>" /><input type="hidden" name="filesize" id="filesize" value="<%=message.getFileSize()%> /><img src ="Images/attachment.jpg" style="bgcolor: #EEE" /><%}else{%><span style="padding-left:12px" ></span><%}%>
<span id="space1" style="padding:6px"></span>
<!--For Display Time and Date of messaging-->
<font color="#000000" size="1"><strong><%=message.getTimestamp()%><span style="padding-left:5px"></span><%=message.getDate()%><input type="hidden" name="label" value="<%=message.getLabel()%>"></strong></font>
</a></td>
</tr><% } %>
請,爲自己的安全:Java不是JavaScript的。 – Kobi 2011-05-15 10:39:16
@Kobi這裏真正的問題確實是JavaScript,但是很難真正看到這一點。 – 2011-05-15 10:46:23
下一次,請將您的標記和代碼發送到瀏覽器(使用'查看源代碼'),以便我們不必知道生成的HTML的外觀。畢竟,這是JavaScript會看到的。 – 2011-05-15 11:13:23