Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
My code is as follows

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


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

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.
Posted
Updated 15-Sep-11 2:48am
v2

1 solution

modify your code as shown below - (replace file_upload with this.form)
HTML
<input type="reset" value="" class="ResetButton1" name="rst_btn" id="rst_btn"  önclick="return reset(this.form);"></input>


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


Hope it may help you out...

Thanks & Regards,
Niral Soni
 
Share this answer
 
v2
Comments
komali Guntur 16-Sep-11 1:15am    
Hi Niral Soni

I modified the code as you send but the problem is it is not even calling the javascript function(reset())when i clicked on the reset button.I kept the alert message just for checking whether the function is calling or not it is not displaying the alert message.I understood that it is not calling the javascript function.What might be the problem
Niral Soni 7-Oct-11 9:29am    
try renaming the function reset to resetForm (as reset being the keyword)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900