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

  • 相关阅读:
    桂林印象
    快变
    近期的事
    *C#中使用ref和out一点认识!*
    *在框架集页面放置TreeView控件时页面跳转的问题解决*
    *无法找到脚本库的问题*
    *Ajax.Net快速入门*
    *网页过期*
    *Prototype开发笔记*
    *正则表达式*
  • 原文地址:https://www.cnblogs.com/ooip/p/4871747.html
Copyright © 2011-2022 走看看