File name : contact.jsp
${contactList} have more than one contacts.
- if checkbox is checked , then it will be added emailList class , if checkbox is unchecked , then email address will be removed from list.
- remove the duplicate email address from list.
- eg : kumar@gmail.com , sam@yahoo.com - here in middle of email address put comma
- finally assign the all email address to parent page id
$("#toAddress").
<c:forEach items="${contactList}" var="contact">
<cong:td>
<input type="checkbox" name="selectContact" id="selectContact" class="emailList" onclick="addEmailinList(${contact.email});"/>
</cong:td>
<cong:td>${contact.accountNo}</cong:td>
<cong:td>${contact.firstName} ${contact.lastName}</cong:td>
<cong:td>${contact.position}</cong:td>
<cong:td>${contact.email}</cong:td>
<cong:td>${contact.phone}</cong:td>
<cong:td>${contact.fax}</cong:td>
</c:forEach>
file name : contact.js
function addEmailinList(ele) {
var mailList = [];
$(".emailList:checked").each(function () {
alert(ele); // here i got email address.
mailList.push(ele);
});
parent.$("#toAddress").val($(".emailList").val());
}
Aucun commentaire:
Enregistrer un commentaire