简体   繁体   English

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

[英]Javascript - How to enable/disable text input in IE9

The following script worked in IE8 but not in IE9: 以下脚本在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;
}

I can display the value of the SHIP_QTY field so I know it's on the page but the disable function does not work. 我可以显示SHIP_QTY字段的值,所以我知道它在页面上,但是disable功能不起作用。

Thanks for your help. 谢谢你的帮助。

If findForm is the name of the form, you want window.findForm rather than document.findForm . 如果findForm是表单的名称,则需要window.findForm而不是document.findForm You can also just use the result of the other field's checked property directly rather than an if/else . 您也可以直接使用其他字段的checked属性的结果,而不是if/else So your code changes to: 因此,您的代码更改为:

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM