Click here to Skip to main content
15,908,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 textboxes , where i show calendar..

so when i select one textbox , it show calendar from which i select date ..

what i want is , when i select first textbox datepicker calendar date, show second textbox calendar automatically to select date .

i tried

in onselect function of first textbox , i use

$("#secondbox").datepicker('show');

This shows calendar , but disappears within 1 second..


what to use,pls provide example code ........
Posted

JavaScript
$(function () {
    $('#TxtExpDte').datepicker();
    $('#TxtStrtDate').datepicker({
        onClose: function (dateText, obj) {
            $("#TxtExpDte").datepicker("show");
        }
    });
});

DEMO[^]

Or use one of Range Date pickers
http://bseth99.github.io/projects/jquery-ui/4-jquery-ui-datepicker-range.html[^]
http://keith-wood.name/datepick.html#range[^]
 
Share this answer
 
v2
Comments
maulikshah1990 16-May-14 4:30am    
hi.thanks for prompt reply...

but i have onselect for both textbox,

so if i include onclose show second calendar in first textbox , it shows me calendar for second ,then if i click date ,it shows calendar once again because i have datepicker on select for second textbox also (i think )...
can u suggest what is issue,..
DamithSL 16-May-14 4:37am    
please update the question with your code
Write your code to get datepicker
$(function() {
    $( "#secondbox" ).datepicker();
  }); 

jQuery UI DatePicker provides option "show" and "hide". So the idea was to show the DatePicker when textbox gets focus (using focus event) and call setTimeout to hide the datepicker after 2 seconds.
$(document).ready(function() {
   $('#secondbox').datepicker();
   $('#secondbox').focus(function() {
     $(this).datepicker("show");
     setTimeout(function() {
       $('#secondbox').datepicker("hide");
       $('#secondbox').blur();
     }, 2000)
   })    
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900