Catfish Posted December 20, 2009 Share Posted December 20, 2009 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? Quote Link to comment Share on other sites More sharing options...
xenophobia Posted December 21, 2009 Share Posted December 21, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.