Login   Register  
PHP Classes
elePHPant
Icontem

File: www/scripts/date.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Graham Trott  >  Target CMS  >  www/scripts/date.js  >  Download  
File: www/scripts/date.js
Role: Auxiliary data
Content type: text/plain
Description: Date script
Class: Target CMS
Content Management System
Author: By
Last change:
Date: 2010-06-28 01:13
Size: 1,151 bytes
 

Contents

Class file image Download
//<script language="JavaScript">

	function populate(inForm, dd, mm, yy)
	{
		var d=parseInt(dd);
		var m=parseInt(mm);
		var y=parseInt(yy);
		var today= new Date();
		if (dd==0) d= today.getDate();
		if (mm==0) m= today.getMonth()+1;
		if (yy==0) y= today.getFullYear();
		for (var i=0; i <31 ; i++)
		{
			inForm.day.options[i] = new Option(String(i+1));
		}
		inForm.day.options[d-1].selected=true;
		inForm.month.options[m-1].selected=true;
		offset=4;
		ty=today.getFullYear();
		if (y+offset>ty) offset=ty-y;
		for (var i=0, j=y+offset; i <10 ; i++, j--)
		{
			inForm.year.options[i] = new Option(String(j));
		}
		inForm.year.options[offset].selected=true;
	}

	function populate2(inForm2)
	{
		var days=0;
		if (inForm2.month.options[1].selected)
			days=28;
		else if (inForm2.month.options[8].selected
			|| inForm2.month.options[3].selected
			|| inForm2.month.options[5].selected
			|| inForm2.month.options[10].selected)
			days=30;
		else
			days=31;
		for (i=0; i<31; i++)
		{
			inForm2.day.options[i]=null;
		}
		for (var i=0; i <days ; i++)
		{
			var x= String(i+1);
			inForm2.day.options[i] = new Option(x);
		}
	}

//</script>