我必须进行伪聊天,在将按钮按下到文本区域上方的框中后,它将从文本区域添加文本。到目前为止,我的代码看起来像这样
<form name="frm1" id="puts">
<textarea name="txt1" COLS=15 ROWS=1></textarea>
<a class="Sisesta Nupp" id="nupp5" href="#"
onclick="alert(document.frm1.txt1.value) +(document.frm1.txt1.value='')"">
<span>Sisesta </span>
</a>
,但是如何将其写入文本区域上方的框中,这样它就不会从上面的框中删除以前写入的内容?如果文本不再适合,如何绘制一个可以滚动的盒子?当我写一些东西时,它应该用列表中的随机句子来回答我。
edit1:由于 html 很糟糕,并且其他两个解决方案(很好)在我的代码中不起作用,我想知道,如何将 document.frm1.txt1.value 附加到我的文本区域上方的框中?
I have to make a pseudo-chat, that will add text fromt textarea after button is pressed to a box above the textarea. So far my code is looking like this
<form name="frm1" id="puts">
<textarea name="txt1" COLS=15 ROWS=1></textarea>
<a class="Sisesta Nupp" id="nupp5" href="#"
onclick="alert(document.frm1.txt1.value) +(document.frm1.txt1.value='')"">
<span>Sisesta </span>
</a>
But how to get it written in a box above the textarea so that it won't erase previously written things from the above box? And how to draw a box, that will make a scroll, if the text doesn't fit anymore? When I write something then it should answer me with a random sentence from a list.
edit1: Since html is crap, and the two other solutions(which were good) don't work in my code, I would like to know, how can I just append the document.frm1.txt1.value in a box above my textarea?
发布评论
评论(2)
使用 jQuery 创建很容易:
jQuery 代码:
HTML:
给你! jsFiddle --编辑:- 修订
It's easy to create with jQuery:
jQuery code:
HTML:
Here you go! jsFiddle --edit:- revised
好吧,我有几分钟的时间(等待 IM 响应),所以我想出了这种可能性,使用稍微修改过的 html:
和 jQuery:
JS Fiddle 演示。
Edited to link to a revised demo (for that 'classic IM' look): JS Fiddle.
Well, I had a few minutes to kill (waiting on IM response), so I came up with this possibility, using the slightly amended html:
and jQuery:
JS Fiddle demo.
Edited to link to a revised demo (for that 'classic IM' look): JS Fiddle.