html渲染-獲取-傳輸table表單數據


1、定義所需的全局js變量(登記)

 

 

 2、$(document).ready(function (){})初始化數據

$(document).ready(function () {

    try {
        document.getElementById("print_word").GetAddress();
        var currUrl = document.location.toString();
        var urlIndex = currUrl.indexOf("PhyExaManagement");
        var currRoot = currUrl.substr(0, urlIndex);
        document.getElementById("print_word").SetWebRequestUrl(currRoot);
    }
    catch (err) {
        var winPlatform = window.navigator.platform;
        if (winPlatform.indexOf("64") != -1) {  //64位平台
            $("#download_activeX_64").css("display", "block");
        }
        else {
            $("#download_activeX_32").css("display", "block");
        }
    }
//渲染html函數
   bindtable();
    
})
3、渲染函數
function bindtable() {
    var searchXX = $("#XX).val();
    $.ajax({
        url: "XXX.ashx",
        dataType: "json",
        type: "post",
        data: {
            "dataType": "XXData",
            "name": searchXX,
            
        },
        success: function (data) {
            if (data.XX1== 1) {
                var dataLength = data.XX2.length;
                var dataHtml = "";
                for (var i = 0; i < dataLength; i++) {
                    var dataInfo = data.XX2[i];
                    dataHtml += "<tr>" +
                        " <td class=\"Td1\"> <div class=\"plr-5\" data-id=\"" + dataInfo.BH + "\" data-xmlx=\"" + dataInfo.XMLX + "\" data-xmxb=\"" + dataInfo.XB + "\" data-tjlx=\"" + dataInfo.ZXKS + "\" data-sflb=\"" + dataInfo.SFLB + "\">" + dataInfo.MC + "</div></td>" +
                        "  <td class=\"Td2\"><div class=\"plr-5\">" + dataInfo.DJ.toFixed(2) + "</div></td>" +
                        "<td class=\"Td3\"><div class=\"plr-5\"><span class=\"tabOperaBtn hover\">選用</span></div></td>" +
                        "  </tr>";
                }
                $("#XXS_table").html(dataHtml);
            }
            else {
                showMsgModal(data.RetMsg);
            }
        }
    });

}

  3、ajax提交數據

 var lx= $(this).find("td.Td div.tr-1").attr("data-lx"); 
var sumPrice =0;
//獲取所有的項目信息
    $("#project_table tbody tr").each(function () {
        var id= $(this).find("td.Td2 div.plr-5").attr("data-id");
        var jg = $(this).find("td.Td2 div.plr-5").attr("data-jg");
        
        sumPrice = sumPrice + parseFloat(jg);

        list[i] = { "lx": Trim(lx), "id": id, "jg": jg , };
        i++;
    });

    if (sumPrice > 0 && isToday(tjrq)) {
      
        list[i] = { "lx": Trim(lx), "id": id, "jg": sumPrice , };
    }

    if (list.length == 0) {
       
        return false;
    }
    $.ajax({
        url: "CompletePhysicalExamination.ashx",
        dataType: "json",
        type: "post",
        data: {
            "dataType": "SaveDJdata",
            "lx": lx,
            
            "projects": JSON.stringify(list)
        },
        success: function (data) {
            lc.hideLoading();
            if (data.RetCode == 1) {
                if (data.RetData == true) {   //保存成功
                  
                  
                }
                else {
                  
                }
            }
            else {
             
            }
        }
    });

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM