日期:2014-05-16  浏览次数:20420 次

js处理大量数据时会报错
下面是写在iframe中的方法,本意是将iframe表格中,凡是前面的checkbox被选中的数据,拼成一个表格传输到父窗口中
JScript code
function AddAttendee()
{
    var trs = $("tr[name='trHcpList']");
    var trs_len = trs.length;
    var hcpListBody = "";
    if(trs_len > 0){
        $.each($(trs).find("input[type='checkbox']"), function(){
            if(this.checked==true)
            {
                var tr = $(this).parent().parent();
                var contactId = $(tr).find("td[name='tdContactId']").text();
                var hcpName = $(tr).find("td[name='tdHcpName']").text();
                var specialty = $(tr).find("td[name='tdSpecialty']").text();
                var accountName = $(tr).find("td[name='tdAccountName']").text();
                var department = $(tr).find("td[name='tdDepartment']").text();
                var state = $(tr).find("td[name='tdState']").text();
                if (specialty == '')
                {
                    var specialty1 ='@^^@';
                }else{
                    var specialty1 =specialty;
                }
                hcpListBody = "<tr><td class='hcp_list_checkbox_field' width='100px' height='25px'>" + 
                "<input type='hidden' name='contactdIdList' value='" + contactId +"'/>" + 
                "<input type='hidden' name='hcpNameList' value='" + hcpName +"'/>" + 
                "<input type='hidden' name='specialtyList' value='" + specialty +"'/>" + 
                "<input type='hidden' name='accountName' value='-" + accountName +"'/>" + 
                "<input type='hidden' name='department' value='-" + department +"'/>" + 
                "<input type='hidden' name='state' value='-" + state +"'/>" + 
                "<input type='hidden' name='specialtyNmList' value='" + specialty1 +"'/>" + 
                "<input type='button' value='Delete' onclick='deleteSlectPrd(this);'/></td>" + 
                "<td class='hcp_list' width='130px'>" + contactId + "</td>" +
                "<td class='hcp_list' width='200px'>" + hcpName + "</td>" +
                "<td class='hcp_list' width='150px'>" + specialty + "</td>" +
                "<td class='hcp_list' width='200px'>" + accountName + "</td>" +
                "<td class='hcp_list' width='150px'>" + department + "</td>" +
                "<td class='hcp_list_checkbox_field' width='120px'>" + state + "</td>" +
                "<td class='hcp_list' style='display:none;'></td></tr>";

                var check = true;
                var trs = $(window.parent.document).find("#divHcpList table tr");
                $.each(trs, function(i, item){
                    if ($(item).find("td input[value='" + contactId + "']").length > 0) 
                    {
                        check = false;
                        return;
                    }
                });

                if (check) {
                    var temp = $(window.parent.document).find("#divHcpList table").val();
                    temp = temp + hcpListBody ;
                    $(window.parent.document).find("#hiddivcontianer").val(temp);

                    $(window.parent.document).find("#divHcpList table tbody").prepend(temp);

                    $(window.parent.document).find("#divHcpListContainer").css("display",&qu