Jump to content

Populate dropdowns with date


iPixel

Recommended Posts

What i'm looking to do is have 6 drop downs,

 

Day1 [          V]      Month1 [            V]    Year1 [          V]

 

Day2 [          V]      Month2 [            V]    Year2 [          V]

 

and what i want is to use javascript to fill in all the fields where Day1Month1Year1 = to current date and Day2Month2Year2 = current date + 3 days.

 

Any tips are really welcomed

THANKS in advance.

Link to comment
https://forums.phpfreaks.com/topic/138788-populate-dropdowns-with-date/
Share on other sites

Ok i got it working, but it's not friendly to IE6... any ideas why.

 

<script language="javascript">
function initdt() 
{
var t = new Date;
document.DateSelect.fd.value = t.getDate();
document.DateSelect.fm.value = t.getMonth() + 1;
document.DateSelect.td.value = t.getDate() + 3;
if(t.getMonth() + 1 == 12)
{
	document.DateSelect.tm.value = t.getMonth() - 10;
}
else
{
	document.DateSelect.tm.value = t.getMonth() + 1;
}
} 
</script>

 

The Day dropdown does not get selected at all in IE6 but works just fine in FF for the second date dropdown day. I know it has something to do with the whole 29+3 does not equal 1 in IE6 but how do i get over that, FF is aparently smart enough to figure out it's 29/30/31/1 as opposed to 32

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.