Jump to content

Custom function() for Form's "Reset" Button


watagal

Recommended Posts

GreetingsWhen a user clicks the "reset" button on a form -- it restores the form elements back to their oringinal values. Yet as usual, I want it to do more - like toggle a <div> display.How can I write a wrapper or tap into the "Reset" button to do more than it's original function?TIA

Link to comment
Share on other sites

Here you go, i've used <form onreset=""> to call a function to show the div.

<head><script>function resetForm(){document.getElementById('mydiv').style.display="block";}</script></head><body><form onreset="resetForm()"><p>name: <input type="text"><br />address: <input type="text"></p><div id="mydiv" style="display:none">Hi, you just pressed reset </div><p><input type="submit" value="submit" /><input type="reset" value="reset" /></p><form></body>

Link to comment
Share on other sites

Thanks all, that's what I was looking for.Playing around with it more I found

<input type="reset" value="Reset" name="btnReset" onclick="dspDiv('divTest','off')">

also works, but I like the 'onreset' event.TA

Link to comment
Share on other sites

  • 1 month later...

The modification you will have to make is within the function, please post the function and not only the line which is calling it. But not here, make a new topic in the PHP forum.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...