Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shruti Bansal
date time picker
2 Answer(s)      3 years and 6 months ago
Posted in : JavaScript Questions


I have enetered a date time picker in my jsp file. there is text field before the date time picker. What should i do so that whenever i click on that text field I am not able to eneter anythng and automatically the date time picker gets opened??


Advertisement
View Answers

June 1, 2011 at 11:29 AM


1)datepicker.html:

<html>
<script type="text/javascript">
function SelectDate(){
    D = document.getElementById('Date').value;
    if(D){
        D = D.split('/');
    }else{
        Dat = new Date();
        D = new Array(Dat.getDay(), Dat.getMonth(), Dat.getFullYear());
    }
    win = window.open("pickmonth.html","win","status=no,scrollbars=no,toolbar=no,menubar=no,height=190,width=160");
    win.MakeDate(D[2], D[1], D[0]);
}
function SetDate(Day, Month, Year){
    document.getElementById('Date').value = Day + '/' + Month + '/' + Year;
}
</script>
<body>
<form name="DateTest">
<input type="text" name="Date" id="Date" readonly><input type="button" onClick="SelectDate()" value="Select"><br>
</form>
</body>
</html>


June 1, 2011 at 11:29 AM


continue..

2)pickmonth.html:

<html>
<head>
<title>Date Picker</title>
<script type="text/javascript">
ReturnFunc = '';
function Calendar(iYear, iMonth, iDay, ContainerId, ClassName){
    MonthNames = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    oDate = new Date();
    Year = (iYear == null) ? oDate.getFullYear() : iYear;
    Month = (iMonth == null) ? oDate.getMonth() : iMonth - 1;
    while(Month < 0){Month += 12;Year--}
    while(Month >= 12){Month -= 12;Year++}
    Day = (iDay == null) ? 0 : iDay;
    oDate = new Date(Year, Month, 1);
    NextMonth = new Date(Year, Month + 1, 1);
    WeekStart = oDate.getDay();
    MonthDays = Math.round((NextMonth.getTime() - oDate.getTime()) / 86400000) + 1;
    if(ContainerId != null){
        ContainerId = ContainerId;
        Container = document.getElementById(ContainerId);
        if(!Container)
            document.write('<div id="' + ContainerId + '">&nbsp;</div>');
    }
    else{
        do{
            ContainerId = 'tblCalendar' + Math.round(Math.random() * 1000);
        }
        while(document.getElementById(ContainerId));
        document.write('<div id="' + ContainerId + '">&nbsp;</div>');
    }
    Container = document.getElementById(ContainerId);
    ClassName = (ClassName == null) ? 'tblCalendar' : ClassName;
    HTML = '<table border=1>';
    HTML += '<tr bgcolor="red"><td ></td><td colspan="5" class="Title">' + MonthNames[Month] + ' ' + Year + '</td><td ></td></tr>';
    HTML += '<tr ><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>';
    HTML += '<tr>';
    for(DayCounter = 0; DayCounter < WeekStart; DayCounter++){
        HTML += '<td>&nbsp;</td>';
    }
    for(DayCounter = 1; DayCounter < MonthDays; DayCounter++){
        if((DayCounter + WeekStart) % 7 == 1) HTML += '<tr class="Days">';
        if(DayCounter == Day)
            HTML += '<td ><a href="javascript:ReturnDate(' + DayCounter + ')">' + DayCounter + '</a></td>';
        else HTML += '<td><a href="javascript:ReturnDate(' + DayCounter + ')">' + DayCounter + '</a></td>';
        if((DayCounter + WeekStart) % 7 == 0) HTML += '</tr>';
    }
    for(j = (42 - (MonthDays + WeekStart)), DayCounter = 0; DayCounter <= j; DayCounter++){
        HTML += '<td>&nbsp;</td>';
        if((j - DayCounter) % 7 == 0) HTML += '</tr>';
    }
    HTML += '</table>';
    Container.innerHTML = HTML;
    return ContainerId;
}
function ReturnDate(Day){
    opener.SetDate(Day, Month+1, Year);
    window.close();
}
function MakeDate(iYear, iMonth, iDay, fn){
    D = new Date();
    Year = (typeof(iYear) != 'undefined') ? iYear : D.getFullYear();
    Month = (typeof(iMonth) != 'undefined') ? iMonth : D.getMonth();
    Day = (typeof(iDay) != 'undefined') ? iDay : D.getDate();
    ReturnFunc = fn;
    id = Calendar(Year, Month+1, Day, 'cal', 'CalendarRed');
}
</script>
</head>
<body onLoad="MakeDate();">
<div id='cal'> </div>
</body>
</html>


Related Tutorials/Questions & Answers:
date time picker
date time picker  I have enetered a date time picker in my jsp file. there is text field before the date time picker. What should i do so... the date time picker gets opened
Date Picker
Date Picker   Hi Java Developers ! I came across the coding for date picker in this site which was almost similar to the coding done by our team... in the calendar( by using date picker ) it needs to get updated/highlighted
Advertisements
Date Picker
Date Picker  "I want to set default calendar date when using datepicker. This date means auto-loaded date when the calendar appears. The default date is the current date. I want to change it. How could I do
Date picker in Java Swing
Date picker in Java Swing  Hello Sir, Sir ,I am in need of Time Picker just like the Date picker available in java Swing. Kindly... link: Java Date Time Picker Example   Hello Sir, Thank
date picker
date picker  where i have to kept javascript ,css files and images in eclipse... please tell me the location
iPhone Date Picker
to show the date which you select on the iPhone date picker with time. The Date...iPhone Date Picker In this tutorial will learn how to use iPhone Date Picker... and to check the attributes for the Date Picker select the Date Picker and then click
date picker - Java Beginners
date picker  sir i need code for date picker in java swing because for Embedding in my project plz sir
Date limit on Dojo Date picker - Date Calendar
picker in my project. When user click on date text box, date picker will pop up... want to Date limit for date picker i.e. If i given date limit from 31/03/2008... this validation by getting value from date picker text box or server side also, but I
javascript date picker - Date Calendar
javascript date picker  how to insert a date picker user control in a html/jsp using javascript??? please help, it's urgent.  Hi Friend, Please visit the following links: http://www.roseindia.net/javascript
date picker componnt - Java Beginners
date picker componnt  sir i need code for date picker in java swing for my project sir please send me sir
How to make Time picker in Java Swing
How to make Time picker in Java Swing  Hello Sir, Thank u so much for such a quick reply . I followed date picker tutorial and completed. but sir i want time picker just like date picker in which we can select hours
How to make Time picker in Java Swing
How to make Time picker in Java Swing  Hello Sir, Thank u so much for such a quick reply . I followed date picker tutorial and completed. but sir i want time picker just like date picker in which we can select hours
How to use Date Picker iPhone
How to use Date Picker iPhone  Hi, I am beginner in mobile Application platform. I want to develop a small application in iphone platform to Show current date and display alert view message. So, how to define the date picker
Dyanmically Adding Rows with Date Picker
Dyanmically Adding Rows with Date Picker  Hi Sir, I am doing a project in that i need to add rows dynamically with date picker inside row, send me code as soon as possible. Regards, Santhosh
get date picker values to a textbox
get date picker values to a textbox  I am using DatePicker to select date in a form in asp.net using c#. I need the picked data to get in to a textbox. Please help me soon
jquery date picker
jquery date picker  how can i compare the dates on click from a calendar with the dates that are stored in database
JTable with Date Picker
JTable with Date Picker  Hi, I'd like to implement the following but I have no idea where to start: I have a JTable with 1 column containing Date... a date which is then shown inside the cell and also modified in the backing object
jquery date picker
jquery date picker  I am developing a business calendar.i used the Jquery datepicker plugin.I just now want to get the dates from the the calendar and should get the alert message soon after i click on the particular date.The
Time Picker in struts 2 - Struts
Time Picker in struts 2  How to create Time Picker in Struts 2 ? ...;head> <title>Struts 2 Time Picker Example!</title>... to get the solutions of your time picker problem in struts 2.RegardsVinod
want a program for date picker by using java swings
want a program for date picker by using java swings  to write a program for the date picker by using java swings.any one please help me by providing the code to this java date picker by using the java swings.previously a program
how to get time picker value in javascript of struts2
how to get time picker value in javascript of struts2  I am not able to get value of time picker in java script . my code is jsp java script var totime=dojo.widget.byId("totime").getValue(); how to get value please help me
Set Date limit for dojo date picker dynamically - Date Calendar
Set Date limit for dojo date picker dynamically  Hi all, I am using Dojo's date picker in my project. I am trying to set min & max value for disable dates from date picker. There are two fields which are using this date
Data Time Picker is not taking as requried field - Struts
Data Time Picker is not taking as requried field   when it going to action what is default value?  Hi Friend, Please visit the following link: http://www.roseindia.net/struts/struts2/date/struts-2-datetimepicker
JavaScript calendar date picker
{ } /* the table (within the div) that holds the date picker calendar */ .dpTable { font... picker We are going to discus about JavaScript calendar date picker. We have used basic JavaScript date picker functionality. We use drop-down calendar
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
Date & Time
Date & Time  How to insert System Date & Time in MS-ACCESS using Java
convert date time to int
convert date time to int  convert date time to int
javascript current date and time.
javascript current date and time.  How can we display current date and time using javascript?   <html> <head> <title>... with current day,date,time and GMT.You can have your own format
JSF Date picker error - Java Server Faces Questions
JSF Date picker error  hi friend thanks for your reply.i tried it already those codes. But those are not working .i don't know what is the error on my code.here i have placed my code. Please kindly send me
Mysql Date and Time
Mysql Date and Time       Mysql Date and Time is used to return the current date and time... the current date and time. CURRENT_TIMESTAMP:-This is used to returns
Date & TIme - Development process
Date & TIme  Hi, I asked to insert Date and Time to database with am... with time. Hi Friend, To insert the date,use the following code in your...() that will insert date with time into database. So to use this method, you have
 

 

 

DMCA.com