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 badges
Add a ment  | 

1 Answer 1

Reset to default 8

Resetting 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