本文介绍了使用jQuery将项添加到asp.net下拉列表中。以下代码不起作用,我缺少什么?请帮忙。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function filterLedgerAccounts() {
var AccType = $("#ACCOUNTTYPE").val();
switch (AccType) {
case "Income": //120*;130*;10*
var allLedger = $get("tbblkProcessCreditN_TabPanel1_ddlAllLedgerAccounts");
var ddlAccLookUp = $("tbblkProcessCreditN_TabPanel1_ddlAccNo");
var incomeCount = 0;
for (var i = 0; i < allLedger.length; i++) {
if (allLedger.options[i].value.match(120) || allLedger.options[i].value.match(130) || allLedger.options[i].value.match(10)) {
incomeCount++;
}
}
ddlAccLookUp.length = incomeCount;
var incomePos = 0;
for (var i = 0; i < allLedger.length - 1; i++) {
if (allLedger.options[i].value.match(120) || allLedger.options[i].value.match(130) || allLedger.options[i].value.match(10)) {
$('#tbblkProcessCreditN_TabPanel1_ddlAccNo').append($("<option value=" + allLedger.options[i].value + ">" + allLedger.options[i].text + "</option>"));
incomePos++;
}
}
break;
case "Expense": //20*;11*
var allLedger = $get("tbblkProcessCreditN_TabPanel1_ddlAllLedgerAccounts");
var ddlAccLookUp = $("tbblkProcessCreditN_TabPanel1_ddlAccNo");
var expenseCount = 0;
for (var i = 0; i < allLedger.length; i++) {
if (allLedger.options[i].value.match(20) || allLedger.options[i].value.match(11)) {
expenseCount++;
}
}
ddlAccLookUp.length = expenseCount;
var expensePos = 0;
for (var i = 0; i < allLedger.length - 1; i++) {
if (allLedger.options[i].value.match(20) || allLedger.options[i].value.match(11)) {
$("tbblkProcessCreditN_TabPanel1_ddlAccNo").append("<option value=" + allLedger.options[i].value + ">" + allLedger.options[i].text + "</option>");
expensePos++;
}
}
break;
case "Control Accounts":
var allLedger = $get("tbblkProcessCreditN_TabPanel1_ddlAllLedgerAccounts");
var ddlAccLookUp = $("tbblkProcessCreditN_TabPanel1_ddlAccNo");
var controlCount = 0;
for (var i = 0; i < allLedger.length; i++) {
if (allLedger.options[i].value.match(9999)) {
controlCount++;
}
}
ddlAccLookUp.length = controlCount;
var controlPos = 0;
for (var i = 0; i < allLedger.length - 1; i++) {
if (allLedger.options[i].value.match(9999)) {
$("tbblkProcessCreditN_TabPanel1_ddlAccNo").append("<option value=" + allLedger.options[i].value + ">" + allLedger.options[i].text + "</option>");
controlPos++;
}
}
break;
}
}
推荐答案
这篇关于使用jQuery将项添加到asp.net下拉列表中。以下代码不起作用,我缺少什么?请帮忙。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!