dtdsbakn210537 2014-11-18 00:14
浏览 33

我试图在javascript中添加一个json对象响应日期数组到一个数组并使用此数组,以便在jquery日历中启用日期

Note that if i directly put my dates into the array enabledDates, it will work.

var enabledDays = [];
    var answ = '';

    function choosedoc(){
        var xmlhttp = getXMLHttpRequest();  
        var actionmode = 1;
        var doctorid = document.getElementById('doctorid').value;


        xmlhttp.onreadystatechange=function(){

            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                var data = $.parseJSON(xmlhttp.responseText);

                var msg = data[0].message;

                if (msg != "") {
                    alert(decodeURIComponent(msg));
                } else { 
                    answ = data[0].some;
                    // this will get an array of dates: 11-11-2014,11-13-2014,11-14-2014
                    alert(enabledDays);
                    if(answ!=''){
                        alert(answ);
                        var result = answ.split(",");
                        //that would split the answer with the , seperator
                        for(i = 0; i < result.length; i++){
                            enabledDays.push("'"+result[i]+"'"); 
                        }
                    }else{
                        enabledDays ='';
                    }
                }
            }
        }
        xmlhttp.open("GET","appointments_ajax.php?actionmode="+actionmode+"&doctorid="+doctorid);
        xmlhttp.send();
    }

    function enableAll(date) {

        var m = date.getMonth() + 1, d = date.getDate(), y = date.getFullYear();
        for (i = 0; i < enabledDays.length; i++) {
            if($.inArray(m + '-' + d + '-' + y,enabledDays) != -1) {
                return [true]; 
            }
        }
        return [false];
    }

    $(function(){
        $('#appointmentdate').datepicker({
            dateFormat:'yy-mm-dd',
            beforeShowDay: enableAll,
        });
    });

When I press the input toolbar, it will display a calendar which will be all disabled except the dates that are in the array

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向