简体   繁体   English

如何从文本框中获取日期和时间选择器值?

[英]How to get Date and Time Picker values from textbox?

I am using date and time picker that not used for getting current date and time instead that is to for user want to select some date and time so for... 我正在使用不用于获取当前日期和时间的日期和时间选择器,而不是用户想要选择一些日期和时间,以便......

This is my code for date and time picker. 这是我的日期和时间选择器代码。

<form class="form-horizontal" id="myForm">
                            <label for="from" class="col-sm-1 col-md-1 col-xs-3 control-label">From:</label>
                            <div class="form-group ">
                                <div class="input-group">
                                    <span class="input-group-addon"> <i
                                        class="fa fa-time"></i>
                                    </span> <input type="text" name="from_time" id="from_time"
                                        class="form-control" placeholder="" readonly="" />
                                </div>
                            </div>
<label for="to" class="col-sm-1 col-md-1 col-xs-3 control-label">To:</label>
                    <div class="form-group ">
                        <div class="input-group">
                            <span class="input-group-addon"><i
                                class="fa fa-time"></i> </span> <input type="text"
                                name="to_time" id="to_time" class="form-control" placeholder=""
                                readonly="">
                        </div>
                    </div>
<label for="date" class="col-sm-1 col-md-1 col-xs-3 control-label">Date:</label>
                    <div class="form-group ">
                        <div class="input-group">
                            <span class="input-group-addon"><i
                                class="fa fa-cal"></i> </span> <input type="text"
                                name="date" id="date" class="form-control" placeholder="" />
                        </div>
                    </div>
<input type="button" onclick="getresult()" value="Submit">
</form>
                    </div>
                </div>
            </div>

and my script code for date and time picker 和我的日期和时间选择器的脚本代码

<script type="text/javascript">
        $(document).ready(function(){
        $('#from_time').timepicker({showMeridian: false});
        $('#to_time').timepicker({showMeridian: false});
        });
</script>
    <script type="text/javascript">
        $(document).ready(function(){
        $('#date').datepicker({ dateFormat: 'mm-dd-yy' }).datepicker("setDate", new Date());

        });
    </script>

and here is how i try to get that result of date and time from text box id 这是我如何尝试从文本框ID获取日期和时间的结果

function getresult(){
    var Date=$("date").val();
    var From_Time=$("from_time").val();
    var To_Time=$("to_time").val();
    alert(Date+" "+From_Time+" "+To_Time);
}

but this gives result like "undefined" "undefined"..in don't know what to do plzzz help me out from this 但是这会给出像“undefined”“undefined”这样的结果..在不知道该怎么做的时候plzzz帮我解决了这个问题

You have to use ID selector # sign to get value. 你必须使用ID选择#号来获取价值。

function getresult(){
    var Date=$("#date").val();
    var From_Time=$("#from_time").val();
    var To_Time=$("#to_time").val();
    alert(Date+" "+From_Time+" "+To_Time);
}

Manual 手册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从日期范围选择器获取值 - How to get values from date range picker 如何获取Javascript中两个日期选择器值之间的时间跨度? - How to get the time span between two date picker values in Javascript? 如何从角形材料日期选择器中获取当前时间? - How to I get current time from angular material Date picker? 如何从Django中的日期选择器获取日期 - How to get the date from the date picker in django 如何使用Clean jQuery Date and Time Picker Plugin设置从一个选择器到另一个选择器的日期-datetimepicker - How to set a date From one picker to another picker using Clean jQuery Date and Time Picker Plugin - datetimepicker 在文本框中键入日期时间,不会更改日期选择器的选定值 - Typing the date time in textbox, does not change the selected value of date picker 如何与日期选择器一起添加时间选择器 - how to add time picker along with date picker 如何在标签和文本框中显示日期选择器值 - How to show date picker value in a label and textbox 如何在 Javascript 中获取日期时间选择器引导程序的值 - How to get value of date time picker bootstrap in Javascript 如何获取日期和时间范围选择器的开始和结束时间? - how to get start and end on date and time range picker?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM