`

表单重置

 
阅读更多
方式一:
    <script type="text/javascript">
        function reset() {
            var form = document.searchForm;
            for (var i = 0; i < form.elements.length; i++) {
                var field = form.elements[i];
                var fieldType = form.elements[i].type.toLowerCase();
                if (fieldType != "submit" && fieldType != "reset" && fieldType != "button" && fieldType != "hidden") {
                    if (fieldType == "radio" || fieldType == "checkbox") {
                        field.checked = false;
                    } else if (fieldType == "select") {
                        field.selected = false;
                    } else {
                        field.value = "";
                    }
                }
            }
        }
    </script>

<form name="searchForm" action="/helpServletTeacher" method="POST">
	<span>辅导状态:</span>
	<select name="status" id="status">
	    <option value="">全部</option>
	    <option value="-2">未确认</option>
	    <option value="-1">待辅导</option>
	    <option value="1">成功</option>
	    <option value="2">未成功</option>
	</select> 
    <input type="button" name="input9" class="bn4" value="重置" onclick="reset()"/>
</form>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics