我有一点cunundrum。我有一个Jquery / Js函数,可以从DropDownList中选择项目。然后将其分配给变量,并将变量传递给另一个函数。我唯一的问题是,当我第一次这样做时,一切正常。当我第二次调用该函数时,变量保持不变,而不是重新分配。
ddlCaseFilesNew,ddlCaseFilesOld,是我的两个DropDownLists。
这是我的功能:
function getCaseFiles(canMoveExpenses) {
//create Popup with content from div
var newCaseDdl = null;
var oldCaseDdl = null;
$('#ddlFiles').dialog({
autoOpen: true,
height: 'auto',
width: 'auto',
modal: true,
buttons: {
"Ok": function () {
//assign new CaseFile and old CaseFile for stored proc.
//var newCaseDdl = "";
newCaseDdl = $("#ddlCaseFilesNew").val();
alert("newCaseDdl = " + newCaseDdl);
// newCaseDdlInt = newCaseDdl.options[newCaseDdl.selectedIndex].value;
//var oldCaseDdl = "";
oldCaseDdl = $("#ddlCaseFilesOld").val();
// oldCaseDdlInt = oldCaseDdl.options[oldCaseDdl.selectedIndex].value;
alert("oldCaseDdl" + oldCaseDdl);
if (newCaseDdl != -1 && oldCaseDdl != -1) {
moveCasefile(canMoveExpenses, newCaseDdl, oldCaseDdl);
$(this).dialog('close');
}
else {
showMessage("Error. Please Select a Value From The Lists.");
}
oldCaseDdl = $("#ddlCaseFilesOld").selectedIndex = -1;
newCaseDdl = $("#ddlCaseFilesNew").selectedIndex = -1;
},
Cancel: function () {
newCaseDdl = null;
oldCaseDdl = null;
$(this).dialog('close');
}
}
});
}
我对Js / JQuery有点新鲜
oldCaseDdl和newCaseDdl是需要chagne到DropDownList的选定索引的变量
答案 0 :(得分:0)
弄清楚原因。我从来没有为DropDownList实现“selection_changed”。