按钮提交后,我的文本区域文本将被清除



下面的代码从用户单击提交按钮后插入的文本区域中删除文本,但我希望文本在提交后位于我的文本区域。

<form action="/search" name="myform" id="formid" method="post"   >
<div class="input-group" >
<!--          

<textarea  name="input" id="textArea" />




<button type="submit" onclick="return fill()" >Search</button>
</button>

</div>

</form>

<script type="text/javascript">
function fill()
{

var x = document.getElementById('textArea').value;
document.getElementById('demo').innerHTML=x;



}
</script>

只需尝试添加onSubmit="return false"在表单标签

<form action="/search" onSubmit="return false;" name="myform" id="formid" method="post"   >

最新更新