Web >> Development >> Javascript >>  How to blank out input form elements

function NewForm(FormName) { for (var i = 0; i < document.forms[FormName].elements.length; i ) { if ( document.forms[FormName].elements[i].type == 'text' ) { document.forms[FormName].elements[i].value = ''; } if ( document.forms[FormName].elements[i].type == 'textarea' ) { document.forms[FormName].elements[i].value = ''; } if ( document.forms[FormName].elements[i].type == 'select-one' ) { document.forms[FormName].elements[i].options[0].selected = true; // this assumes that the first option element contains blank } } return true; }