-2

使用 Asp.Net 和 Java 脚本

从 Datatime 控件中,我正在选择应该添加组合框的多个数据。

Java 脚本

function closed(cal) {
    $("#txtIndividualDays").val("");
    var noDays = 0;
    var ddlDate = document.getElementById("sIndividualDays");
    var opt;
    ddlDate.options.length = 0;

    MA.length = 0;

    var countDays = 0;
    for (var i in cal.multiple) {
        countDays++;
    }
    var arrDays = new Array(countDays);
    countDays = 0;
    if (arrDays.length == 0) {
        opt.text = "Select Date";
        opt.value = "-1";
        $("#txtIndividualDays").val($("#txtIndividualDays").val() + opt.text + ";");
    }
    for (var i in cal.multiple) {
        arrDays[countDays] = i;
        countDays++;
    }
    for (var i in arrDays.sort()) {
        var d = cal.multiple[arrDays[i]];
        var isWeekend = false;
        var isHoliday = false;
        if (d) {
            var _date;
            _date = d.print("%m/%d/%Y");
            opt.text = d.print("%m/%d/%Y");
            opt.value = d.print("%m/%d/%Y");
            MA[MA.length] = d;
            document.getElementById("txtIndividualDays").value += opt.text + ";";
        }
    }
    document.getElementById("txtWorkingDays").value = noDays;
    var control = $("#sIndividualDays");
    var itemCount = $("#sIndividualDays option").length;
    cal.hide();
    return true;
};

上面的脚本在选择单个日期时显示错误。我的脚本有什么问题。需要脚本帮助

4

1 回答 1

0

我不确定这些行是否正确:

var opt;
..............
opt.text = "Select Date";
opt.value = "-1";
...........

我建议你改为:var opt = new Object();

于 2013-04-01T08:58:48.280 回答