您的位置:首页 > 其它

处理字符串中的换行,将textarea中的带有换行的字符串变为逗号分隔的写法

2013-10-12 18:19 483 查看
_setMultipleInputValues: function (param) {
//Maybe need to modify here for the new parameter
//add a method to set input values from textarea
if (param.Name == "AddedParameter1") {
bindingElement = true;
var textareaValue = "";
textareaValue = $("#" + param.Name + "_textarea").val();
var c;
for (var i = 0; i < textareaValue.length; i++)
{
c = textareaValue.substr(i, 1);
if (c == "\n")
{
textareaValue = textareaValue.replace("\n", ",");
}
}
$("#" + param.Name + "_fore").val(textareaValue.substr(0, textareaValue.length - 1));
}
else {
var showValue = "";
var hiddenValue = "";
$("." + param.Name + "_DropDown_CB").each(function () {
if (this.checked && this.value !== "Select All") {
showValue += $("[name='" + param.Name + "_DropDown_" + this.value + "_lable']").html() + ",";
hiddenValue += this.value + ",";
}
});
$("#" + param.Name + "_fore").val(showValue.substr(0, showValue.length - 1));
$("#" + param.Name + "_hidden").val(hiddenValue.substr(0, hiddenValue.length - 1));
}
},


_setMultipleInputValues
直接上代码,下面截图做说明:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: