dongzhou1865
dongzhou1865
2013-05-29 17:03
浏览 38

提交jQuery多日期选择器表单作为POST数据

I love this jQuery datepicker that I want to implement on a PHP form with other input boxes http://multidatespickr.sourceforge.net/

When the user hits a submit button they are brought to another page update.php where the form data is obtained via POST.

I'm looking for a line to add to the javascript so I can somehow access the array of multiple dates in the multiple datepicker via POST:

var latestMDPver = $.ui.multiDatesPicker.version;
        var lastMDPupdate = '2012-03-28';
  var dates = $('#simpliest-usage').multiDatesPicker('getDates');



            // Version //
            //$('title').append(' v' + latestMDPver);
            $('.mdp-version').text('v' + latestMDPver);
            $('#mdp-title').attr('title', 'last update: ' + lastMDPupdate);


            // Documentation //
            $('i:contains(type)').attr('title', '[Optional] accepted values are: "allowed" [default]; "disabled".');
            $('i:contains(format)').attr('title', '[Optional] accepted values are: "string" [default]; "object".');
            $('#how-to h4').each(function () {
                var a = $(this).closest('li').attr('id');
                $(this).wrap('<'+'a href="#'+a+'"></'+'a>');
            });
            $('#demos .demo').each(function () {
                var id = $(this).find('.box').attr('id') + '-demo';
                $(this).attr('id', id)
                    .find('h3').wrapInner('<'+'a href="#'+id+'"></'+'a>');
            });

            // Run Demos
            $('.demo .code').each(function() {
                eval($(this).attr('title','NEW: edit this code and test it!').text());
                this.contentEditable = true;
            }).focus(function() {
                if(!$(this).next().hasClass('test'))
                    $(this)
                        .after('<button class="test">test</button>')
                        .next('.test').click(function() {
                            $(this).closest('.demo').find('.box').removeClass('hasDatepicker').empty();
                            eval($(this).prev().text());
                            $(this).remove();
                        });
            });
        });
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzhi0107
    douzhi0107 2013-05-29 17:12

    Looking at the plugin you can store the range as a common seperated list in a regular input field. Use jquery to disable to field from direct entry so people can't "mess it up" then after you post you an implode the field on a comma and then you will have your array.

    http://multidatespickr.sourceforge.net/#undefined-demo

    点赞 评论
  • douhuang3833
    douhuang3833 2013-05-29 17:19

    I'm not sure if that's what you're looking for, but if you need to access the dates passed to the script via POST just do this:

    $dates = explode(',', $_POST['simpliest-usage']);
    
    点赞 评论

相关推荐