[英]New Line in textarea problem
Hello all I created a textarea and I can "enter" a new line in it all day but when I submit the box. 大家好,我创建了一个textarea,可以整天在其中输入新行,但需要提交框。 Its all one continuous sentence.
它是所有连续的句子。 Any thoughts??
有什么想法吗??
<tr id="commentRow">
<td>
You have <strong><span id="commentsCounter">${const['COMMENT_MAX_LENGTH'] - fn:length(commentForm.comment)}</span></strong> characters left.<br/>
<textarea id="comment" name="comment" rows="2" cols="125" style="width:360px;"
onkeypress="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
onkeydown="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"
onkeyup="characterCounter('commentsCounter',${const['COMMENT_MAX_LENGTH']}, this)"></textarea>
<a href="javascript:addComment();"><img src="../images/icon_add.gif" border="0" alt="Add"/></a>
</td>
<td class="shaded" colspan="1"> </td>
</tr>
is there something I need to add to the jsp?? 有什么我需要添加到jsp中的吗?
Hey buddy below this is prior to adding the 嘿哥们,这是在添加以下内容之前
<form id="commentForm" name="commentForm" action="" method="post"> <ctl:vertScroll height="300" headerStyleClass="data_table_scroll" bodyStyleClass="data_table_scroll" enabled="${user.scrollTables}"> <ctl:sortableTblHdrSetup topTotal="false" href="show.whatif_edit_entry?entryId=${entry.entryId}"/> <table class="data_table vert_scroll_table" style="width:360px;"> <tr> <ctl:sortableTblHdr styleClass="center" title="Comments" property="comment" type="top">Comments</ctl:sortableTblHdr> <ctl:sortableTblHdr styleClass="center" title="Created By" property="auditable.createdBy.lastName" type="top">Entered By</ctl:sortableTblHdr> </tr> <c:forEach var="comments" items="${entry.comments}"> <tr id="id${comments.id}"> <td id="comments-${comments.id}" class="wrappable" style="width:360px;" >${comments.comment}</td>
Then I added the
<tr id="id${comments.id}"> <td id="comments-${comments.id}" class="wrappable" style="width:360px;" ><pre>${comments.comment}</pre></td>
The table then expanded HUGE!!!!! 然后桌子扩大了!!!!
any thoughts??? 有什么想法吗???
If you want to display data from a textarea as html you will need to convert any \\n
characters into <br>
(or <br />
for XHTML) tags, otherwise they'll show up in your source but not on your page. 如果要以html格式显示文本区域中的数据,则需要将所有
\\n
字符转换为<br>
(或XHTML为<br />
)标记,否则它们将显示在您的源代码中,而不是在您的页面上。
Alternatively wrapping the whole thing in <pre></pre>
tags will also work as this will treat the text as pre-formatted and display it like a text editor (saving tabs and whitespace). 另外,也可以将整个内容包装在
<pre></pre>
标记中,因为这会将文本视为预格式化,并像文本编辑器一样显示(保存标签和空格)。
If you were to output whatever is entered in the textarea into the <td class="shaded">
you'd change that to <td class="shaded" colspan="1"><pre>
textarea input displayed here </pre></td>
如果要将在文本区域中输入的任何内容输出到
<td class="shaded">
请将其更改为<td class="shaded" colspan="1"><pre>
在此处显示的文本区域输入 </pre></td>
However you are displaying the submitted data probably isn't taking into account the newline characters that you are submitting. 但是,您显示的是提交的数据,可能没有考虑您提交的换行符。 I would see if there are any \\r or \\n characters to change to new lines "
<br />
" in HTML. 我将查看是否有\\ r或\\ n字符可更改为HTML中的新行“
<br />
”。
use this in textarea value to break line to new 在textarea值中使用它可以将行换成新的
\n\n
tested as required 根据要求测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.