zoukankan      html  css  js  c++  java
  • textarea内容有换行时存入数据库丢失问题的解决 (转载)

    http://blog.csdn.net/zhang_j_h/article/details/44563167

    存入:

    function GetInputData(id, cmd) {
    var postdata = "{ "action":"" + cmd + "",";
    $("#" + id + " input[type!='checkbox']").each(function () {
    postdata += """ + $(this).attr("name") + "":"" + $(this).val() + "",";
    });
    $("#" + id + " input[type='checkbox']").each(function () {
    postdata += """ + $(this).attr("name") + "":"" + this.checked + "",";
    });
    $("#" + id + " select").each(function () {
    postdata += """ + $(this).attr("name") + "":"" + this.value + "",";
    });
    $("#" + id + " textarea").each(function () {
    postdata += """ + $(this).attr("name") + "":"" + this.value.replace(/ | /g, "<br>") + "",";
    });
    postdata = postdata.substr(0, postdata.length - 1);
    postdata += "}";
    return eval("(" + postdata + ")");
    }

    提交:var json = GetInputData("AthleteViolationInfoForm", "submit");

    读取:

    $("#ipt_actionresult").val(dataObj.ipt_actionresult.replace(/<br>/g, ' '));//读取数据时把数据匹配正则替换正确的回车符号(符合的编码,用于正确显示)

    alue.replace(/<br>/g, "");//替换换行为空

  • 相关阅读:
    POJ 2155 Matrix
    Codeforces 626D Jerry's Protest 「数学组合」「数学概率」
    Codeforces 626E Simple Skewness 「数学」「二分」
    Codeforces 633D
    Codeforces 631C
    二分查找
    CodeForces 617C【序枚举】
    HDU 4405 【概率dp】
    ZOJ 3329 【概率DP】
    POJ 2096 【期望DP】
  • 原文地址:https://www.cnblogs.com/ooip/p/4871747.html
Copyright © 2011-2022 走看看