重置表单,不使用javascript吗? (输入类型=重置无效) [英] Reset a form, without javascript? (input type=reset not working)
问题描述
好吧,我想标题说明了一切. 我正在寻找一种重置表单内所有字段的方法. 我尝试了以下一些方法:
Well, I guess the title says it all. I'm looking for a way to reset all the fields within a form. I've tried some of the following:
<input type="reset" value="Clear all fields">
还有
<button type="reset">Clear all fields</button>
但是,这些似乎都不起作用.
Yet, none of this seems to be working.
这是我表格的精简版.
<form id="form2" action="mainframe.php?paso=21" method="POST">
<input type="reset" value="Reset">
<button type="reset" form="form2">Reset</button>
<?php while($row=$resultado->fetch_assoc()){ ?>
<p>Number of <?php echo $row['name']; ?>
<input type="text" name="saldo[<?php echo $row['id']; ?>]" value="<?php echo $row['saldo']; ?>" maxlength="30" />
<?php } ?>
</form>
<button type="submit" form="form2">Send</button>
编辑:显然,reset
按钮会将所有inputs
的值替换为页面加载时的值.仅当未声明input
的value
属性或页面加载为空时,该按钮才会清除所有字段并将其保留为空白.
Apparently the reset
button will replace the values of all inputs
with the values they had on page load. The button would clear all fields and leave them blank only if the input
's value
property aren't declared or are null on page load.
推荐答案
摆脱掉您对输入值的回声,它应该可以工作...
get rid of what u echo to the input value and it should work...
这篇关于重置表单,不使用javascript吗? (输入类型=重置无效)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!