bparmelee
asked on
Reset Button Not Working
Why does nothing happen when I click on the reset button? Also, is there a way to set focus back to the text box when a user clicks reset?
Here is the current code where reset is not working:
<form name="search" method="get" onsubmit="return testSearchValue(this)" action="search.html">
<input type="hidden" name="page_number" value="1"/>
<input type="text" name="user_input" size="30" style="height:24"/>
<input type="image" border="0" src="images/go.gif" alt="Go!" width="37" height="24" align="top"/>
<a href="javascript:document. search.use r_input.re set()">
<img src="images/reset.gif" alt="Reset" border="0" width="74" height="24" align="top"\>
</a>
</form>
If have tried calling this javascript from onClick in the <a> above and nothing happens:
function resetSearch()
{
document.search.user_input .reset();
document.search.user_input .focus();
}
Thanks!
Here is the current code where reset is not working:
<form name="search" method="get" onsubmit="return testSearchValue(this)" action="search.html">
<input type="hidden" name="page_number" value="1"/>
<input type="text" name="user_input" size="30" style="height:24"/>
<input type="image" border="0" src="images/go.gif" alt="Go!" width="37" height="24" align="top"/>
<a href="javascript:document.
<img src="images/reset.gif" alt="Reset" border="0" width="74" height="24" align="top"\>
</a>
</form>
If have tried calling this javascript from onClick in the <a> above and nothing happens:
function resetSearch()
{
document.search.user_input
document.search.user_input
}
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very cool! Thanks!
The reason your code above didn't work is because you can't "reset" a textbox. You have to set its value to nothing. It's also better to run JavaScript through an onClick rather than the javascript: protocol.