Bookmark this on Delicious
Here's a simple javascript function that you can call to reset all elements in a form:
function ClearForm () { var thisForm = document.forms[0]; for(i=0; i < thisForm.elements.length; i++ ) { if ( thisForm.elements[i].type == "text" || thisForm.elements[i].type == "textarea" ) { thisForm.elements[i].value = ""; } else if (thisForm.elements[i].type == "select-one") { thisForm.elements[i].selectedIndex = 0; } } }
In this example I reset the first form and I reset textboxes, textarea's and select's.
Example
DISCLAIMER: This information is provided "as is". The author, publishers and marketers of this information disclaim any loss or liability, either directly or indirectly as a consequence of applying the information presented herein, or in regard to the use and application of said information. No guarantee is given, either expressed or implied, in regard to the merchantability, accuracy, or acceptability of the information.