0

Hi,
how to pass variable value inside js.
i want to add Days value to From date and dispaly it as To date
here is my code,please go through it,i have explained in comments

HTML
days:<input type="text" id="capped_days">//manual i/p
From:<input id="dt1" type="text">//date picker1
To:<input id="dt2" type="text">//datepicker2

javaScript

 $("#dt1").datepicker({
            dateFormat: "dd-M-yy",
            minDate: 0,
            onSelect: function (date) {
                var cap_days=document.getElementById('capped_days').value;
                alert(cap_days);
                var date2 = $('#dt1').datepicker('getDate');
                date2.setDate(date2.getDate() + 50);//it adds 50 days to FROM date,and display  To date  but i want to pass variable cap_days value insted of 50
                //if i pass any integer vale like 50,70..its working fine ,but i want to pass value dynamically based on user input.
                $('#dt2').datepicker('setDate', date2);
                //sets minDate to dt1 date + 1
                $('#dt2').datepicker('option', 'minDate', date2);
            }
        });
        $('#dt2').datepicker({
            dateFormat: "dd-M-yy",
            onClose: function () {
                var dt1 = $('#dt1').datepicker('getDate');
                console.log(dt1);
                var dt2 = $('#dt2').datepicker('getDate');
                if (dt2 <= dt1) {
                    var minDate = $('#dt2').datepicker('option', 'minDate');
                    $('#dt2').datepicker('setDate', minDate);
                }
            }
        });

        please help me as soon as possible.thank you

Edited by shashigowda

2
Contributors
1
Reply
19
Views
1 Year
Discussion Span
Last Post by AleMonteiro
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.