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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧