2013-10-22 98 views
0

我有一個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('');但運行其他一切都很好。

+0

什麼返回對子級 「tfRAItem.getValue()」?它可能永遠不會爲空字符串 – webduvet

+0

有什麼症狀告訴你它沒有擊中tfRAPA.setValue('')? – asantaballa

+0

什麼是playframework標籤在這裏做什麼? – Carsten

回答

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); 
} 
+1

應OP播放「找到差異」? –