<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Handeling the dates and the leap year with AJAX and jQuery</title>
	<atom:link href="http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handeling-the-leap-year-with-ajax-and-jquery</link>
	<description>Yet Another Coding Blog</description>
	<lastBuildDate>Fri, 23 Sep 2011 08:55:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Wojtek</title>
		<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/comment-page-1/#comment-64</link>
		<dc:creator>Wojtek</dc:creator>
		<pubDate>Thu, 20 Nov 2008 14:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.designing4u.de/?p=6#comment-64</guid>
		<description>Yes, you are right, changing the year drop down doesn&#039;t repopulate the month drop down. In the case you just described though:

&quot;if they select year-&gt;month-&gt;day and then reselect year-&gt;month it will not contain the correct value of the day they had previously selected before changing the year again&quot;

you did not consider a user selecting a leap year and February 29th and re-selecting a non leap year. In this case you cannot re-populate 29th.

You can obviously do that by repopulating both of the fields (months and days - every time user changes a year drop down and the day drop down is not disabled) using AJAX and some calculations in PHP. As arguments in your AJAX request you would pass the existing values chosen by a user and check if they validate with a new year. If not repopulate the new fields with changed values. If a user changes the month drop down, you will need to add a check if day drop down is disabled, if not pass the value of the day drop down and check if it validates with the new month. The rest is the same. If you need the code for that, let me know, I will write it.

I think though, that the best solution for this would be repopulating months and days again. Basically every time a user changes the year, he or she needs to choose the complete date again. To do that you could also add an AJAX request to retrieve the months. I hope this will help you. Let me know.</description>
		<content:encoded><![CDATA[<p>Yes, you are right, changing the year drop down doesn&#8217;t repopulate the month drop down. In the case you just described though:</p>
<p>&#8220;if they select year->month->day and then reselect year->month it will not contain the correct value of the day they had previously selected before changing the year again&#8221;</p>
<p>you did not consider a user selecting a leap year and February 29th and re-selecting a non leap year. In this case you cannot re-populate 29th.</p>
<p>You can obviously do that by repopulating both of the fields (months and days &#8211; every time user changes a year drop down and the day drop down is not disabled) using AJAX and some calculations in PHP. As arguments in your AJAX request you would pass the existing values chosen by a user and check if they validate with a new year. If not repopulate the new fields with changed values. If a user changes the month drop down, you will need to add a check if day drop down is disabled, if not pass the value of the day drop down and check if it validates with the new month. The rest is the same. If you need the code for that, let me know, I will write it.</p>
<p>I think though, that the best solution for this would be repopulating months and days again. Basically every time a user changes the year, he or she needs to choose the complete date again. To do that you could also add an AJAX request to retrieve the months. I hope this will help you. Let me know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coral</title>
		<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/comment-page-1/#comment-63</link>
		<dc:creator>Coral</dc:creator>
		<pubDate>Thu, 20 Nov 2008 13:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.designing4u.de/?p=6#comment-63</guid>
		<description>Correction: I mean it doesn&#039;t set proper day values if client selects year-&gt;month-&gt;day and then reselects just year and leaves month alone.</description>
		<content:encoded><![CDATA[<p>Correction: I mean it doesn&#8217;t set proper day values if client selects year-&gt;month-&gt;day and then reselects just year and leaves month alone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coral</title>
		<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/comment-page-1/#comment-62</link>
		<dc:creator>Coral</dc:creator>
		<pubDate>Thu, 20 Nov 2008 12:56:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.designing4u.de/?p=6#comment-62</guid>
		<description>Hi, thanks for the reply.  But if you add

$(document).ready(function(){  
         $(&#039;#year&#039;).change(function(){  
            $(&#039;#month&#039;).removeAttr(&#039;disabled&#039;);
               if ($(&#039;#day&#039;).attr(&#039;disabled&#039;) != &#039;disabled&#039;) { // new code
               $(&#039;#day&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;).html(&#039;&#039;); //new code
            } //new code
                 
         });  
...
It submits the correct number of days only if the client reselects the number of days. For, example, if they select year-&gt;month-&gt;day and then reselect year-&gt;month it will not contain the correct value of the day they had previously selected before changing the year again, just an unpopulated dropdown select [.html(&#039;&#039;)]. I am new to Jquery; so I tried saving the $(#day.selectedIndex) in a var then setting it to that back to the default drop down value and redisplaying back in the day dropdown box, but it&#039;s not working.... Or if I get that day box value back to the default value (which in my case in value=&quot;default&quot;, then the form can validate that and warn the client they must select a day (value= 1 or value = 2 etc).</description>
		<content:encoded><![CDATA[<p>Hi, thanks for the reply.  But if you add</p>
<p>$(document).ready(function(){<br />
         $(&#8216;#year&#8217;).change(function(){<br />
            $(&#8216;#month&#8217;).removeAttr(&#8216;disabled&#8217;);<br />
               if ($(&#8216;#day&#8217;).attr(&#8216;disabled&#8217;) != &#8216;disabled&#8217;) { // new code<br />
               $(&#8216;#day&#8217;).attr(&#8216;disabled&#8217;, &#8216;disabled&#8217;).html(&#8221;); //new code<br />
            } //new code</p>
<p>         });<br />
&#8230;<br />
It submits the correct number of days only if the client reselects the number of days. For, example, if they select year-&gt;month-&gt;day and then reselect year-&gt;month it will not contain the correct value of the day they had previously selected before changing the year again, just an unpopulated dropdown select [.html('')]. I am new to Jquery; so I tried saving the $(#day.selectedIndex) in a var then setting it to that back to the default drop down value and redisplaying back in the day dropdown box, but it&#8217;s not working&#8230;. Or if I get that day box value back to the default value (which in my case in value=&#8221;default&#8221;, then the form can validate that and warn the client they must select a day (value= 1 or value = 2 etc).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wojtek</title>
		<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/comment-page-1/#comment-55</link>
		<dc:creator>Wojtek</dc:creator>
		<pubDate>Thu, 13 Nov 2008 11:17:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.designing4u.de/?p=6#comment-55</guid>
		<description>Hi Coral,

yes, you are right, reentering the year does not change the day and it should be take into consideration. You can do it by adding the condition in onchange event:

if ($(&#039;#day&#039;).attr(&#039;disabled&#039;) != &#039;disabled&#039;) {
    $(&#039;#day&#039;).attr(&#039;disabled&#039;, &#039;disabled&#039;).html(&#039;&#039;);
}

This will disable and remove all days from the day drop down again.</description>
		<content:encoded><![CDATA[<p>Hi Coral,</p>
<p>yes, you are right, reentering the year does not change the day and it should be take into consideration. You can do it by adding the condition in onchange event:</p>
<p>if ($(&#8216;#day&#8217;).attr(&#8216;disabled&#8217;) != &#8216;disabled&#8217;) {<br />
    $(&#8216;#day&#8217;).attr(&#8216;disabled&#8217;, &#8216;disabled&#8217;).html(&#8221;);<br />
}</p>
<p>This will disable and remove all days from the day drop down again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Coral</title>
		<link>http://www.designing4u.de/2008/05/handeling-the-leap-year-with-ajax-and-jquery/comment-page-1/#comment-54</link>
		<dc:creator>Coral</dc:creator>
		<pubDate>Thu, 13 Nov 2008 10:53:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.designing4u.de/?p=6#comment-54</guid>
		<description>Hi:

Yeah, this works well if the user selects year-&gt;month-&gt;day but if for example, they select year(2012)-&gt;month(February)-&gt;day(29), but then go back and decide to change the year to 2010 it will still have the values February and 29 which will submit wrong values for the year 2010.  I have tried from scratch ajax also with or without JQuery and still having trouble with that issue. I suppose you could disable the year option once it is selected or reset everything and set month and day back to default every time a new year is selected.... I&#039;m almost to the point of just using a graphical widget to solve this...</description>
		<content:encoded><![CDATA[<p>Hi:</p>
<p>Yeah, this works well if the user selects year-&gt;month-&gt;day but if for example, they select year(2012)-&gt;month(February)-&gt;day(29), but then go back and decide to change the year to 2010 it will still have the values February and 29 which will submit wrong values for the year 2010.  I have tried from scratch ajax also with or without JQuery and still having trouble with that issue. I suppose you could disable the year option once it is selected or reset everything and set month and day back to default every time a new year is selected&#8230;. I&#8217;m almost to the point of just using a graphical widget to solve this&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

