是否可以清除表单并用一个按钮重置(重新加载)页面? [英] Is it possible to clear a form and reset (reload) the page with one button?

查看:148
本文介绍了是否可以清除表单并用一个按钮重置(重新加载)页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一个表单,用户在其中键入内容,然后结果返回并显示在页面上。我是否有可能同时清除搜索结果和表单的按钮?



我知道您可以使用< input type =resetvalue =Reset/> 按钮以重置表单并使用以下代码重新加载页面。



< input type =buttonvalue =清除结果onClick =window.location.reload()>



是否可以让按钮执行两项操作,即清除搜索结果并重置表单?如果是这样的话,可以用JavaScript来完成吗?

谢谢 解决方案

 <输入类型=输入类型= resetvalue =ResetonClick =window.location.reload()> 

(现在您可以接受我的答案XD)

I've got a form on a page where the user types something in and then a result is returned and displayed on the page. Is it possible for me to have a button that will both, clear the search results and the form simultaneously?

I know that you can use the <input type="reset" value="Reset"/> button on the form to reset the form and also use the following code, to reload the page.

<input type="button" value="Clear Results" onClick="window.location.reload()">

Is it possible to have the button do both things i.e. clear the search results and reset the form? Can it be done using JavaScript, if so how?

Thanks

解决方案

If you want the functionality of both of the snippets you posted, you can simply combine them.

<input type="reset" value="Reset" onClick="window.location.reload()">

(There, now you can accept my answer XD)

这篇关于是否可以清除表单并用一个按钮重置(重新加载)页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆