重置表单(把表单的所有输入元素重置为它们的默认值。): 1.使用reset按钮,条件reset按钮必须在form表单内部。 2. <input id="Button1" type="button" value="button" οnclick="form1.reset();" />可以不在表单内部。 用途示例:一般我们做添加页面和编辑页面时用的都是同一个页面,这样以来编辑后再添加时表单内容就需要清除,很多人在使用后台代码做清除工作如: protected void btnAdd_Click(object sender, EventArgs e) ModalPopup.Show(); 实际上我们可以更简单些,使用js脚本来实现: <asp:Button ID="btnAdd" runat="server" Text="添 加" CausesValidation="False" OnClientClick="form1.reset();ModalPopup.style.display='';" /> 或者 <input id="Button1" type="button" value="button" οnclick="form1.reset();ModalPopup.style.display='';" /> 另外: 有些项(下拉框、复选列表、单选列表)我们只要有默认值,reset并不会把它们清除掉,而是自动设置成默认项。 <asp:TextBox ID="TextBox1" runat="server">aaa</asp:TextBox> <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:DropDownList ID="DropDownList1" runat="server"> onsubmit,onreset的用法: <script type="javascript"> } reture false;表示该事件完成之后,不再交给IE默认处理了, |
form表单的reset
最新推荐文章于 2024-07-21 11:35:59 发布
form表单的reset