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, "");//替换换行为空

  • 相关阅读:
    背景不动,内容滚动的解决方案(移动端)
    移动端真实1px的实现方法
    用户模板和用户场景
    构建之法阅读笔记02
    学习进度六
    NABCD
    构建之法阅读笔记01
    学习进度五
    梦断代码阅读笔记03
    地铁系统
  • 原文地址:https://www.cnblogs.com/ooip/p/4871747.html
Copyright © 2011-2022 走看看