我遇到目标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>
答案 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来重置文本字段:)