提交表单后保留textarea内容 [英] keeping textarea content after a form submission

查看:81
本文介绍了提交表单后保留textarea内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提交表格后,我试图在其字段中保留文本框和textarea内容

I am trying to keep a textbox and textarea content in its field after a form submission

文本框代码:

<div class="response">
<span>
<input class="textbox" id="textbox1" name="textbox1" type="text"
       value="<?php if(isset($_POST['textbox1'])) {
                 echo htmlentities ($_POST['textbox1']); }?>" />
</span> </div>

文本区号:

<div class="response">
<span>
<textarea  class="textarea" id="textarea1"
           name="textarea1" type="text"
           value="<?php if(isset($_POST['textarea1'])) { 
                     echo htmlentities ($_POST['textarea1']); }?>" >
</textarea>
</span>
</div>

文本框代码工作正常,但是我无法保留文本区域的内容.

textbox code is working fine, but I am not able to keep the text area content.

推荐答案

您必须添加以下代码,

<textarea  class="textarea" id="textarea1" name="textarea1" type="text">
  <?php if(isset($_POST['textarea1'])) { 
         echo htmlentities ($_POST['textarea1']); }?>
</textarea>

Textarea没有值属性.

Textarea does not have value attribute.

因此,在打开和关闭textarea标签之间添加PHP代码.

So add PHP code between opening and closing textarea tag.

这篇关于提交表单后保留textarea内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆