![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
textarea如何获取JS变量值?
请教个问题:我把textarea的值经JS正则处理后存入数据库,取出时用JS正则处理一下,可如何才能把这个值传回textarea呢<scriptlanguage="jav...
请教个问题:我把textarea的值经JS正则处理后存入数据库,取出时用JS正则处理一下,可如何才能把这个值传回textarea呢
<script language="javascript">
var str = <%=rs2("briefintro5")%>
var reg=new RegExp("<br>","g");
var reg1=new RegExp(" ","g");
str = str.replace(reg,"\r\n");
str = str.replace(reg1," ");
document.getElementById("content").value=str;
</script>
<textarea name="content" cols="100" rows="18" class="wenbenkuang" id="content" </textarea> 展开
<script language="javascript">
var str = <%=rs2("briefintro5")%>
var reg=new RegExp("<br>","g");
var reg1=new RegExp(" ","g");
str = str.replace(reg,"\r\n");
str = str.replace(reg1," ");
document.getElementById("content").value=str;
</script>
<textarea name="content" cols="100" rows="18" class="wenbenkuang" id="content" </textarea> 展开
推荐于2016-04-09 · 知道合伙人互联网行家
关注
![](https://wyw-base.cdn.bcebos.com/pc-content/follow.gif)
展开全部
js 获取、设置textarea的值
<textarea id="txta">test</textarea>
<script type="text/javascript">
var txt;
txt = document.getElementById('txta').value; //获取textarea的值
document.write (txt);
document.getElementById('txta').value = "txt2"; //设置textarea的值
</script>
<textarea id="txta">test</textarea>
<script type="text/javascript">
var txt;
txt = document.getElementById('txta').value; //获取textarea的值
document.write (txt);
document.getElementById('txta').value = "txt2"; //设置textarea的值
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//这样试试
<textarea name="content" cols="100" rows="18" class="wenbenkuang" id="content" </textarea>
<script language="javascript">
var str = '<%=rs2("briefintro5")%>';
var reg=new RegExp("<br>","g");
var reg1=new RegExp(" ","g");
str = str.replace(reg,"\r\n");
str = str.replace(reg1," ");
document.getElementById("content").value=str;
</script>
<textarea name="content" cols="100" rows="18" class="wenbenkuang" id="content" </textarea>
<script language="javascript">
var str = '<%=rs2("briefintro5")%>';
var reg=new RegExp("<br>","g");
var reg1=new RegExp(" ","g");
str = str.replace(reg,"\r\n");
str = str.replace(reg1," ");
document.getElementById("content").value=str;
</script>
更多追问追答
追问
还是不行,我感觉JS代码没有被执行,把var str = '';换成var str = 555,TEXTAREA还是得不到值
追答
TEXTAREA 放在js代码的上面了吗?
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询