Solved

How can I set the default time / date

Posted on 2012-03-20
3
325 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

19 Experts available now in Live!

Get 1:1 Help Now