使用javascript重置表单 [英] resetting the form using javascript

查看:74
本文介绍了使用javascript重置表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的代码如下

< input type ="reset" value =" class ="ResetButton1" name ="rst_btn" id ="rst_btn" onclick ="reset(file_upload);" >


Hi
My code is as follows

<input type="reset" value="" class="ResetButton1" name="rst_btn" id="rst_btn" onclick="reset(file_upload);" >


function reset(file_upload)
{
alert('hi');
document.getElementById("tr1").style.visibility="hidden";
document.getElementById("file_upload").reset();
return false;
}


其中file_upload是表单的ID,tr1是我要隐藏的特定字段的ID.

我保留了警报信息,仅用于验证.但是,当我单击重置"按钮时,它没有校准reset()函数,那么我的代码中有什么问题.


谁能帮忙吗?


where file_upload is the id oh the form and tr1 is the id of the particular field i want to hide.

I kept the alert essage just for verification.But when i click on the reset button it is not caling the reset() function is there any thing wrong in my code.


Can any one please help.

推荐答案

修改代码,如下所示-(用 this.form file_upload ) >)
modify your code as shown below - (replace file_upload with this.form)
<input type="reset" value="" class="ResetButton1" name="rst_btn" id="rst_btn"  önclick="return reset(this.form);"></input>



然后,在您的JavaScript函数中,



then, in your JavaScript function,

function reset(formObj)
{
    alert('hi');
    formObj.reset();
    document.getElementById("tr1").style.visibility="hidden";
    return false;
}



希望对您有帮助...

谢谢&问候,
尼拉·索尼(Nial Soni)



Hope it may help you out...

Thanks & Regards,
Niral Soni


这篇关于使用javascript重置表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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