简体   繁体   中英

Getting daterangepicker value

I'm only able to return the first date selected and I want to be able to get one string containing it all!

I've done some research that brought me to many similar questions like this one : link but I can't get the answer I'm looking for

This is my code:

HTML

<!-- Date range -->
        <div class="form-group">
            <label>Période:</label>
            <div class="input-group">
                <div class="input-group-addon">
                    <i class="fa fa-calendar"></i>
                </div>
                <input type="text" class="form-control pull-right" id="reservation" onchange=""/>
            </div><!-- /.input group -->
        </div><!-- /.form group -->

JAVASCRIPT

        $(function () {
            //Date range picker
            $('#reservation').daterangepicker({
                onSelect: function (d, i) {
                    if (d !== i.lastVal) {
                        $(this).change();
                    }
                }
            });
        });

        $(document).ready(function () {
            $("#reservation").change(function () {
                var date = $("#reservation").val() + "-" + $("#reservation").daterangepicker("getDate");
                $("#partialtable").load('@(Url.Action("GetDateResults", "Temps", null, Request.Url.Scheme))?date=' + date);
            });
        });

If I select the date range: 06/01/2017 - 06/22/18 , I'm only getting "06/01/2017" in my controller.

UPDATE

"var date" contains the correct value, but it seems to cut the string at the first white space when sending value to controller action.

Thanks!

此链接解决了我的问题,解决方案是删除空格,因为该值包含一些空格。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM