title: if condition for .datepicker attributes in javascript
body: <p>I have a datepicker and i want defaultDate attribute, if it will satisfy my condition. Here is a code below,</p>
  
  <pre><code> $(function () {
                  jQuery('#datepicker').datepicker({
                    &lt;% if (parseInt(location.search.indexOf('did=')) &gt;= 0) { %&gt;
                          defaultDate: getDefaultDateVal(),
                     &lt;% } %&gt;
                     //     defaultDate: parseInt(location.search.indexOf('did=')) &gt;= 0 ? getDefaultDateVal() : new Date(),
                          inline: true,
                          maxDate: '+10D',
                          onLoad:function(){alert("hello");},
                          onSelect: function(date) {
                              //alert('Diet plan for ' + date);
                          var d = new Date("January 01, 1970 00:00:00");
                          var d2 = new Date(date);
                          d.setMonth(d.getMonth());
                          var theMonth;
                          theMonth = d.toString();
                          theMonth = theMonth.substr(4, 3);
  
                          d2.setMonth(d2.getMonth());
                          var theMonth2;
                          theMonth2 = d2.toString();
                          theMonth2 = theMonth2.substr(4, 3);
  
                          var firstDay = d.getDate();
                          var secondDay = d2.getDate();
                          var firstMonth = theMonth;
                          var secondMonth = theMonth2;
                          var firstYear = d.getFullYear();
                          var secondYear = d2.getFullYear();
                          var firstDate = new Date(firstDay + " " + firstMonth + " " + firstYear);
                          var secondDate = new Date(secondDay + " " + secondMonth + " " + secondYear);
                          var daysDiff = (secondDate.valueOf() - firstDate.valueOf());
                          daysDiff = Math.floor(Math.abs((((daysDiff / 1000) / 60) / 60) / 24));
                          //alert(daysDiff);
  
  
                          self.location.href = './Goal.aspx?did=' + daysDiff + '';
                          //filterGetMidHead(date);
                          //wait(500);
  
                          //   alert(date);
                          var startdate = ((d2.getDate()).toString().length == 1) ? "0" + (d2.getDate()).toString() : (d2.getDate()).toString();
                          var enddate = new Date();
                          enddate.setDate(d2.getDate() + 7);
                          var enddate1 = ((enddate.getDate()).toString().length == 1) ? "0" + (enddate.getDate()).toString() : (enddate.getDate()).toString();
                          //  alert(enddate1 + "hello");
                          var month2 = ((d2.getMonth() + 1).toString().length == 1) ? "0" + (d2.getMonth() + 1).toString() : (d2.getMonth() + 1).toString();
                          var endatemonth = ((enddate.getMonth() + 1).toString().length == 1) ? "0" + (enddate.getMonth() + 1).toString() : (enddate.getMonth() + 1).toString();
  
                          //alert(new Date().setDate(d2.getDate() + 7));
                          document.getElementById('&lt;%=lblHeaderDate1.ClientID %&gt;').innerHTML = startdate + "/" + month2 + "/" + d2.getFullYear();
                          document.getElementById('&lt;%=lblHeaderDate2.ClientID %&gt;').innerHTML = enddate1 + "/" + endatemonth + "/" + enddate.getFullYear();
                          //    testnew();
                      }
                  });
  
                    &lt;% if (Convert.ToString(Session["LanguageID"])=="IS") 
                         { %&gt;
                      jQuery("#datepicker").datepicker(jQuery.datepicker.regional['is']);
                      &lt;% } %&gt;
  
                  //jQuery("#datepicker").datepicker(jQuery.datepicker.regional['is']);
  
  
                  //hover states on the static widgets
                  jQuery('#dialog_link, ul#icons li').hover(
                          function () { jQuery(this).addClass('ui-state-hover'); },
                          function () { jQuery(this).removeClass('ui-state-hover'); }
                      );
              });
  </code></pre>
  
  <p>But it is showing me an error. Can anyone help me how to write if condition to set datepicker attribue in 
  <code>$("defaultDate: parseInt(location.search.indexOf('did=')) &gt;= 0 ? getDefaultDateVal() : new Date(),").datepicker</code>?</p>