javascript - How to get Date and Time Picker values from textbox? - Stack Overflow

I am using date and time picker that not used for getting current date and time instead that is to for

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

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

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

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

Share asked Jan 15, 2015 at 4:31 manigandandmanigandand 2,1843 gold badges17 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You have to use ID selector # sign to get value.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745068410a4609395.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信