0
我有以下代碼。Javascript選擇不更新
function validateStatuses(bill_id){
var bill = bills[bill_id];
var selects = $('#bill_'+bill.bill_id+' .status_select');
var codes = $('#bill_'+bill.bill_id+' .status_code');
var value = null;
for (var i = 0; i < selects.length; i++) {
//value = document.getElementById('#Item_'+Item.item_id+'statuses'+codes).value;
value = selects[i].options[selects[i].selectedIndex].value;
if (value == 'new'){
for (var j = 0; j < codes.length; j++) {
var blagh = codes[j].options[codes[j].selectedIndex].text;
if(value == 'new' && blagh == "none"){
//A status exist of NEW with a status code of NONE this is not acceptable
$('#info_dialog').html('');
$('#info_dialog').append("<p>You are trying to process an object with a View of NEW and a This CODE of NONE. Please correct this issue before you proceed!</p><hr />");
$('#info_dialog').dialog({
buttons:{
Cancel: function(){
$(this).dialog('close');
}
}
});
return false;
}//end if
}//end for
}else{
}//end if
}//end for
return true;
}//end function
我想只有當值的條件==「新」 & & blagh ==「無」遇到了錯誤顯示。如果變量值已經被設置爲除new以外的值,這將起作用。但是,如果變量是新的,並且我不更改所選的blagh索引,則條件仍然失敗。 只有當value == new時更改value和blagh的值時纔會接受該條件。該函數從onCLick事件運行,我認爲這會強制值變量更新爲新的選定索引。我在這裏錯過了什麼?有什麼建議麼?
是的,這是非常多的。 – 2012-01-12 15:52:33