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?

Link to comment
Share on other sites

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

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.