Jump to content

Make calendar open on today instead of alert message


Catfish

Recommended Posts

Hi, I am not really good in Javascript, but I am building some php scripts that I want to use a JS calendar in for date selection. I have got the JS calendar working but now I am doing a PHP script that lets me edit values already in a database and date values can default to 0000-00-00. The JS calendar script I have doesn't like this and says I have to have a month value from 1 to 12.

 

I have found where it is throwing this alert in the JS code, but what I want to do is modify that code so instead of throwing the warning alert about the month value it will choose today's date.

 

The calendar code is public domain and is available from: http://www.softcomplex.com/products/tigra_calendar/

 

The section of code throwing the alert is in file: calendar_db.js

and looks like:

if (n_month < 1 || n_month > 12)
	return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");

if I change it to:

if (n_month < 1 || n_month > 12)
	n_month = 12;

 

the calendar will load and have November as the month. I figure if I can make the code of that if() block grab today's date and set it to the calendar's date values it would do what i want but I don't know how to get today's date?

Hi, I am not really good in Javascript, but I am building some php scripts that I want to use a JS calendar in for date selection. I have got the JS calendar working but now I am doing a PHP script that lets me edit values already in a database and date values can default to 0000-00-00. The JS calendar script I have doesn't like this and says I have to have a month value from 1 to 12.

 

I have found where it is throwing this alert in the JS code, but what I want to do is modify that code so instead of throwing the warning alert about the month value it will choose today's date.

 

The calendar code is public domain and is available from: http://www.softcomplex.com/products/tigra_calendar/

 

The section of code throwing the alert is in file: calendar_db.js

and looks like:

if (n_month < 1 || n_month > 12)
	return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");

if I change it to:

if (n_month < 1 || n_month > 12)
	n_month = 12;

 

the calendar will load and have November as the month. I figure if I can make the code of that if() block grab today's date and set it to the calendar's date values it would do what i want but I don't know how to get today's date?

 

Check out:

http://www.w3schools.com/js/js_obj_date.asp

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.