如何在DATABASE中提交表单后重置文本字段(使用目标iframe)

时间:2017-08-19 04:17:30

标签: php

我遇到目标iframe问题。我希望在表单完成提交/数据插入数据库

后重置字段

提前致谢!

                    <form method="POST" name="chatform" autocomplete="off" target="iframe">
                    <div class="panel-footer">
                        <input type="hidden" name="user" value="<?php echo $username; ?>">
                        <div class="input-group">
                            <input id="btn-input" type="text" name="chat" class="form-control input-sm" placeholder="Type your message here..." />
                            <span class="input-group-btn">
                                <button class="submit btn btn-info btn-sm" name="send">
                                    <i class="fa fa-send-o"></i>
                                </button>
                            </span>
                        </div>
                    </div>
                    </form>

                    <iframe width="0" height="0" frameborder="0" name="iframe"></iframe>

3 个答案:

答案 0 :(得分:2)

您可以使用javascript

 <form method="POST" onsubmit="return formSubmit()" id="frame" ....


 <script>
   $("#frame").reset();
   return true;
</script>

它会在提交之前重置。

答案 1 :(得分:1)

请查看onsubmit以获得干净的解决方案。

<form method="POST" name="chatform" autocomplete="off" target="iframe" onsubmit="this.reset();">

答案 2 :(得分:1)

<form method="POST" id="frame" name="chatform" autocomplete="off" target="iframe">

</form>                                           

<iframe width="0" height="0" frameborder="0" name="iframe" onload="parent.document.getElementById('frame').reset();"></iframe>

我在iframe中使用onload来重置文本字段:)