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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.