Solved

How can I set the default time / date

Posted on 2012-03-20
3
341 Views
Last Modified: 2012-03-31
Hi,

I am using this AJAX time picker: http://www.ama3.com/anytime/#AnyTime.picker.ajaxOptions

I have 3 fields in my form, EventDate, StartTime, EndTime

Using this script, I want to set the date to the first of x month. Meaning, It's March 20 now, so the default date would be March 1 2012 in the picker. Now when it becomes April, it would be set to April 1 2012.

StartTime and EndTime I want to have set default at 12:00 AM for both.

How can I accomplish that?

Thanks
0
Comment
Question by:Computer Guy
3 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 37741444
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 37741553
I'm looking for the answer to the specific example i provided.
0
 
LVL 1

Accepted Solution

by:
haravallabhan earned 500 total points
ID: 37741831
Call this function at the end of the script or html page.
function firstDayOfMonth() {
    var yourDate= new Date();
    var firstDate= new Date(yourDate.getFullYear(), yourDate.getMonth() - 1, 1);
    document.myform.EventDate.value=AnyTime.format(firstDate);
}

myform is your form name and the EventDate is the name of your field. Similarly you can do it for the time as well. You can change  document.myform.EventDate.value t jQuery mode as $(#EventDate).value...
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now