Javascript - 如何在IE9中启用/禁用文本输入

Javascript - How to enable/disable text input in IE9

本文关键字:文本 输入 启用 IE9 Javascript      更新时间:2023-09-26

以下脚本在IE8中有效,但在IE9中不起作用:

function toggleSelect(fieldName)
{
    var idx = fieldName.lastIndexOf("_");
    var sub = fieldName.substring(19,idx);
    if (document.findForm["cb_Row_PageAutoDelete_" + sub].checked) {
          document.findForm["SHIP_QTY_" + sub].disabled=false ;
    } else {
        document.findForm["SHIP_QTY_" + sub].disabled=true ;
    }
    return true;
}

我可以显示SHIP_QTY字段的值,所以我知道它在页面上,但禁用功能不起作用。

感谢您的帮助。

如果findForm是表单的名称,则需要window.findForm而不是document.findForm。您也可以直接使用其他字段的 checked 属性的结果,而不是if/else 。因此,您的代码更改为:

function toggleSelect(fieldName)
{
    var idx = fieldName.lastIndexOf("_");
    var sub = fieldName.substring(19,idx);
    window.findForm["SHIP_QTY_" + sub].disabled = window.findForm["cb_Row_PageAutoDelete_" + sub].checked;
    return true;
}