我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

替换textarea换行符以将文本保存到Mysql

I need to replace the newlines in a textarea with the string ", " for storing it in a database. For example, the following string, taken from the textarea:

hi!
line break!

Would be replaced with:

hi!, line break!

Try .value.replace(/ /g, ''). This will replace all occurrences of new line in the text area with empty string.

var textWithoutLineBreak = document.getElementById('txtArea').value.replace(/
/g,'');
console.log(textWithoutLineBreak);
<textarea id="txtArea">hi!
line break!
</textarea>

</div>

近期文章

  • 我收到NULL数据以响应cURL请求
  • oci_execute():ORA-01400:无法插入NULL
  • PHP - DB2许可证文件位置
  • 在Woocommerce 3+上通过PHP更改产品可见性
  • 在laravel中获得单一价值
  • 为动物熊创建一个PHP类
  • 将字符串转换为它的对应实体
  • 如何删除foreach循环中的最后一个值
  • 使用Slim框架上传图像时出错
  • 从Google Translate API获取PHP变量的翻译
  • 使用Kartik selectbox yii2设置默认值
  • 在数据对象laravel api中添加更多值
  • 如何在3个相关表之间创建条件
  • TYPO3 isDir,getRealPath在Controller上不起作用
  • 求助:数据库的MySql访问被拒绝
  • 选中复选框时,调用Ajax或提交按钮
  • 在第一次出现之前剪切字符串BEFORE另一个字符串2
  • PHP Data Mapper,具有域之间的递归MTM关系
  • 使用php检查复选框的解决方案。 认为我必须使用一个值
  • 如何在wordpress中更改作者永久链接?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华