Reset form by looping through elements

Function to reset form values.

function resetForm(theForm){
    for(i=0; i<theForm.elements.length; i++)
    {
        if(theForm.elements[i].type == "text")
        {
            theForm.elements[i].value = '';
        }
        else if(theForm.elements[i].type == "select-one")
        {
            theForm.elements[i].selectedIndex = 0;
        }
    }
}

other possible form elements: textarea, checkbox