admin管理员组文章数量:1419194
I have a page which reads from a file and displays filtered results depending on what is entered in the search boxes. When I click the reset button it clears the search boxes which is what I want, but I also want the filtered results to be cleared too. If I unment the call below, which is mented at the moment - it works but the search boxes do not clear.
HTML:
<form>
<ul data-bind="foreach:properties">
<li><input data-bind="attr:{placeholder:id},event:{change:$root.onInputChange}, value:value, valueUpdate: 'afterkeydown'" /></li>
</ul>
<input type="reset" value="Reset"/>
<!--<input type="reset" value="Reset" data-bind="click:$root.onclick"/>-->
</form>
<p></p>
<table data-bind="foreach:itemsFiltered">
<tr data-bind="foreach:$parent.formatItem($data)">
<td data-bind="text:value"></td>
</tr>
</table>
I need the search boxes and filtered results to clear.
I have a page which reads from a file and displays filtered results depending on what is entered in the search boxes. When I click the reset button it clears the search boxes which is what I want, but I also want the filtered results to be cleared too. If I unment the call below, which is mented at the moment - it works but the search boxes do not clear.
HTML:
<form>
<ul data-bind="foreach:properties">
<li><input data-bind="attr:{placeholder:id},event:{change:$root.onInputChange}, value:value, valueUpdate: 'afterkeydown'" /></li>
</ul>
<input type="reset" value="Reset"/>
<!--<input type="reset" value="Reset" data-bind="click:$root.onclick"/>-->
</form>
<p></p>
<table data-bind="foreach:itemsFiltered">
<tr data-bind="foreach:$parent.formatItem($data)">
<td data-bind="text:value"></td>
</tr>
</table>
I need the search boxes and filtered results to clear.
Share Improve this question edited May 17, 2018 at 1:06 cela 2,5203 gold badges25 silver badges46 bronze badges asked Jan 15, 2015 at 13:04 yigamesyigames 1851 gold badge6 silver badges24 bronze badges1 Answer
Reset to default 8Resetting a form resets the fields in it back to their default values (as specified by the value
attribute). It doesn't clear the fields unless the default values are blank.
Your JavaScript is setting value
attributes.
If you want to blank the fields, you'll need to set their value
property to an empty string instead of simply resetting the form.
本文标签: javascriptReset button does not clear fields in HTML5Stack Overflow
版权声明:本文标题:javascript - Reset button does not clear fields in HTML5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745290822a2651781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论