如果Else Statement无法正常工作

时间:2013-10-22 12:38:15

标签: javascript extjs if-statement

我有一个if-else语句并且已经在其上设置了某些条件。我有两个文本字段,并有一个if-else语句根据我在另一个文本字段中的输入填充其中一个文本字段。我有它,如果用户输入'TS'然后它在另一个tetfield中设置'TP'的值。这工作得很好。但是,如果用户输入“TS”然后输入“TP”的其他值为空,我也想设置它。我不能让那部分工作在我的if-else声明中。

if (cbRAType.getValue()=='TS'){
    tfRAPA.setValue('TP');
    if (tfRAItem.getValue()!='') {
        tfRAItemSuf.enable(); tfRAItemSuf.setReadOnly(false);
    }
    else {
        tfRAPA.setValue(''); tfRAItemSuf.setValue(''); tfRAItemSuf.disable(); tfRAItemSuf.setReadOnly(true);
    }
}

它不执行tfRAPA.setValue('');但其他一切都很好。

1 个答案:

答案 0 :(得分:1)

你只是混淆了括号

if (cbRAType.getValue()=='TS'){
    tfRAPA.setValue('TP');
    if (tfRAItem.getValue()!='') {
        tfRAItemSuf.enable(); tfRAItemSuf.setReadOnly(false);
    }
} else {
        tfRAPA.setValue(''); tfRAItemSuf.setValue(''); tfRAItemSuf.disable(); tfRAItemSuf.setReadOnly(true);
}
相关问题