日期:2014-05-16  浏览次数:20366 次

避免多次保存提交的js脚本

<table class="table-button">
??????? <tr>
??????????? <td>
??????????????? <input name="save" type="button" value="保存" onClick="return doSubmit()">
??????????????? <input name="back" type="reset" value="重置">
??????????? </td>
??????? </tr>
??? </table>
?????


<script type="text/javascript">

???? function doSubmit() {
???????? if (!check()) return false;
??????? document.forms[0].action = "<%=rootPath%>/Action.do";
??????? setAllDisabled(document.forms[0]);
??????? document.forms[0].submit();
???? }
??? function check(){
??????? if(document.getElementById("linkman").value==""){
??????????? alert("请输入联系人!");
?document.getElementById("linkman").focus();
??????????? return false;
??????? }

??return confirm("是否继续确认?");
?}

???? function setAllDisabled(obj) {
??????? for (var i = 0; i < obj.all.length; i++) {
??????????? if (obj.all[i].type == "button" || obj.all[i].type == "reset" || obj.all[i].type == "submit") {
??????????????? obj.all[i].disabled = true;
??????????? }
??????? }
??? }
</script>

?

?

================

button置灰的控制

????document.all.BC.disabled = true;
????document.all.CZ.disabled = true;

?