Thursday, April 21, 2011

JQuery datepicker defaultdate from another datepicker

Hi, I have several jquery datepickers on my asp page and I want to set the defaultdate of date picker to be the same as the previous datepicker.

I am currently using

defaultDate: document.getElementById('<%=txtFirstDate.ClientID%>').value

This works okay, but obviously errors if firstDate is null. Should I be using OnSelect function instead?

Appreciate any help

From stackoverflow
  • var defaultDate = document.getElementById('<%=txtFirstDate.ClientID%>').value;
    
    defaultDate: defaultDate || 'default-value'
    
    Maton : Thanks Alex. This method only works if txtFirstDate already has a value in it when I load the page. If txtFirstDate is null when I load the page and I select a value on its datepicker, the txtSecondDate will not pull through the txtFirstDate but rather default-value

0 comments:

Post a Comment