Share on Google+Share on Google+

Shruti Bansal
date time picker
2 Answer(s)      5 years and 10 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??

Ads

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
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads