Cant assign value from getElementById to date?
<p>I've got this:</p>

<pre><code>    var lDate = document.getElementById('txtLeaveDate');
    var rDate = document.getElementById('txtReturnedDate');
</code></pre>

<p>Err...javascript so how do I assign the value of txtLeaveDate to a date variable</p>

<p>I tried:</p>

<p><code>var myDate = new Date(lDate.value);</code></p>

<p>But this assigns some long value....</p>

<p>I can do it if I try:</p>

<pre><code>var today = new Date();
  var day2 = new Date();
  day2.setDate(today.getDate() + 30);
</code></pre>

<p>But the issue is I need to get the date from txtLeaveDate not by a date variable</p>

<h1>edit complete code</h1>

<pre><code>var theLDate = new Date(lDate.value);
        var theRDate = new Date(rDate.value);

        //check if return date is a sunday, if it is no need
        //to do anything,
        //else make it a sunday
        while (theRDate.getDay() != 0) 
            theRDate.setDate(theRDate.getDate() + 1);

        //at this point RDate is a sunday...
        while(theLDate.valueOf() &lt;= theRDate.valueOf())
            {
                if(theLDate.getDay() == 0)
                    {   //sunday
                        var li = document.createElement('li');
                        li.setAttribute('id', ['liID' + count]);
                        var month = theLDate.getMonth();
                        var day = theLDate.getDate();
                        var year = theLDate.getFullYear();
                        var theDay = month + '/' + day + '/' + year + ' (Sunday)';
                        li.innerHTML = theDay;
                        ul.appendChild(li);
                    }   
                theLDate.setDate(theLDate.getDate() + 1);
                count++;
            } 
</code></pre>

<p>But when I pick 2 dates in my calendar like so:</p>

<p><img src="http://i.stack.imgur.com/I00Oy.png" alt="enter image description here"></p>
