Jump to content

Optimisation of a function


Matpatnik

Recommended Posts

Hi guys,I have this function that I have modified a little bitI want to know if their is a better way of doing it.

	function dateChanged(calendar) {		// Beware that this function is called even if the end-user only		// changed the month/year. In order to determine if a date was		// clicked you can use the dateClicked property of the calendar:		if (calendar.dateClicked) {			// OK, a date was clicked, redirect			var y = calendar.date.getFullYear();			var m = calendar.date.getMonth() + 1; // integer, 0..11 (+ 1 to the integer)			if (m < 10) {				m = "0" + m // integer, 01..12			}			var d = calendar.date.getDate(); // integer, 1..31			if (d < 10) {				d = "0" + d // integer, 01..31			}			// redirect...			window.location = "/index.php?lang=$lang&section=calendar&y=" + y + "&m=" + m + "&d=" + d;		}	};

I don't know a lot javascript but I knew by mixing a string with an integer I will get a result close enough.Thank you for your helpMatpatnik

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...