faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 38 people (18%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How to clear a form on a page refresh or reload without clear button in Netscape

Aug 11th, 2006 16:54
David Alden, Tony Vigliano,


<html>
	<form name="thisForm">
		<input type="text" name="thisText" value="this text 
box">
		    
		<textarea name="thisTextarea" >Some sample 
text</textarea>
		<br>
		<br>
		<input type="button" value="Are there Text Boxes on 
this page?">
	</form>
<script type="text/javascript" language="javascript">
	for(var i = 0; i < document.forms.length; i++){
		for(var z = 0; z < document.forms[i].length; z++){
			if(document.forms[i].elements[z].type!
="button")
				document.forms[i].elements[z].value="";
		}
	}
</script>
</html>