0

我的 php Web 应用程序中有两个 jcarousel 滑块,一个用于选择月份,另一个用于与该月相关的日期,我想使用 jquery ajax 来完成,无论我选择哪个月份,所有日期都应该出现在第二个滑块中,有什么办法请帮忙。

4

1 回答 1

1

首先设置月份和日期基本html。

<ul id="months" class="jcarousel-skin">
    <li>Jan</li>
    <li>Feb</li>
    <li>Mar</li>
    <li>Apr</li>
    <li>May</li>
    <li>Jun</li>
    <li>Jul</li>
    <li>Aug</li>
    <li>Sep</li>
    <li>Oct</li>
    <li>Nov</li>
    <li>Dec</li>
</ul>

<ul id="dates" class="jcarousel-skin">

</ul>

现在在 javascript 中设置月份的轮播和日期 ajax

$(document).ready(function(){
    $('#months').jcarousel();

    // Assuming you are going to load months' dates onclick
    $('#months > li').click(function(){
        $.ajax({
            url : 'your-server-script.php?month=' . $(this).text(),
            success : function(data){
                /* Return the dates as html in li tags from server
                    <li>1, Friday</li><li>2, Saturday</li> .... <li>30, whatever</li>
                   and put in the dates ul.
                   You can also pass json(or any other format) and create the html here and put it in.
                */
                $('#dates').html(data);

                // Now setup the dates carousel.
                $('#dates').jcarousel();
            }
        });
    });

});

希望这可以帮助。如果您有更多问题,请与 html 一起粘贴。

于 2012-06-22T11:58:36.070 回答