首页 > 解决方案 > Chrome 中未获取变量的值

问题描述

我在 Javascript 中有以下代码片段

<td ALIGN=\"CENTER\" CHAROFF=\"1\">
<button NAME=\"Add\" TYPE=\"button\" SIZE=\"20\"  " + addButtonDisable + " onClick=\"processForm(this.value)\">Add</button>
<font face=\"Times New Roman\" size=\"6\">      </font>
<button NAME=\"Update\" TYPE=\"button\" SIZE=\"20\" VALUE=\"Update\" " + updateButtonDisable + " onClick=\"processForm(this.value)\">Update</button>
</td>
</tr>

此处单击“添加”或“更新”按钮应调用 processForm(this.value) 函数。我在这里面临的问题是 this.value 在 IE11 中返回正确的值,但是当我在 Chrome 或 Edge 浏览器中尝试相同的事情时,它给了我 this.value 的空值。为什么 this.value 在这里不兼容?还有其他方法可以在这里实现吗?

下面是processForm函数

function processForm(message) {
    if (!validate()) {
        return(false);
    }
    
    document.EMPLOYEE.AddOrUpdate.value = message;
    window.status = message;
    
    if (window.status = document.EMPLOYEE.EMPLOYEEID.value == "0") {
        alert("Please select a Reviewer.");
    } else {
        
        var browser = IdentifyBrowserIE();
        
        if(browser == "IE"){
            document.EMPLOYEE.submit();
        }else{
            document.forms["EMPLOYEE"].submit();
        }
    }
}

标签: javascriptjsp

解决方案


推荐阅读