Hi..

Hi..

View Answers

September 9, 2009 at 5:44 PM

Hi Friend,

Try the following code:
1)calendar.jsp:

<html>
<script language="javascript" type="text/javascript" src="calendar.js">
</script>
<table>
<tr><td>Date Of Birth</td><td><input type="Text" id="demo1" maxlength="25" size="25"><a href="javascript:displayCalendar('demo1','ddmmmyyyy')"><img src="calendar.png" width="16" height="16" border="0" alt="Pick a date"></a></td>
</tr>
<tr><td>Date Of Joining</td><td><input type="Text" id="demo2" maxlength="25" size="25"><a href="javascript:displayCalendar('demo2','ddmmmyyyy')"><img src="calendar.png" width="16" height="16" border="0" alt="Pick a date"></a></td>
</tr>
</table>
</html>

2)calendar.js:

var cal;
var todayDate=new Date();
var Cal;
var docCal;
var MonthName=["January", "February", "March", "April", "May", "June","July",
"August", "September", "October", "November", "December"];
var WeekDayName=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var exDateTime;
var cnTop="200";
var cnLeft="500";
var WindowTitle ="DateTime Picker";
var WeekChar=2;
var CellWidth=20;
var DateSeparator="-";
var TimeMode=24;
var ShowLongMonth=true;
var ShowMonthYear=true;
var SundayColor="violet";
var SaturdayColor="white";
var WeekDayColor="white";
var FontColor="blue";
var TodayColor="yellow";
var SelDateColor="white";
var YrSelColor="black";
var ThemeBg="";
function displayCalendar(pCtrl,pFormat)
{
Cal=new Calendar(todayDate);
if (pCtrl!=null)
Cal.Ctrl=pCtrl;
if (pFormat!=null)
Cal.Format=pFormat.toUpperCase();

exDateTime=document.getElementById(pCtrl).value;
if (exDateTime!="")
{
var Sp1;
var Sp2;
var tSp1;
var tSp1;
var strMonth;
var strDate;
var strYear;
var intMonth;
var YearPattern;
Sp1=exDateTime.indexOf(DateSeparator,0)
Sp2=exDateTime.indexOf(DateSeparator,(parseInt(Sp1)+1));

if ((Cal.Format.toUpperCase()=="DDMMYYYY") || (Cal.Format.toUpperCase()=="DDMMMYYYY"))
{
strMonth=exDateTime.substring(Sp1+1,Sp2);
strDate=exDateTime.substring(0,Sp1);
}
else if ((Cal.Format.toUpperCase()=="MMDDYYYY") || (Cal.Format.toUpperCase()=="MMMDDYYYY"))
{
strMonth=exDateTime.substring(0,Sp1);
strDate=exDateTime.substring(Sp1+1,Sp2);
}
if (isNaN(strMonth))
intMonth=Cal.GetMonthIndex(strMonth);
else
intMonth=parseInt(strMonth,10)-1;
if ((parseInt(intMonth,10)>=0) && (parseInt(intMonth,10)<12))
Cal.Month=intMonth;

if ((parseInt(strDate,10)<=Cal.GetMonDays()) && (parseInt(strDate,10)>=1))
Cal.Date=strDate;

strYear=exDateTime.substring(Sp2+1,Sp2+5);
YearPattern=/^\d{4}$/;
if (YearPattern.test(strYear))
Cal.Year=parseInt(strYear,10);
}
cal=window.open("","DateTimePicker","toolbar=0,status=0,menubar=0,fullscreen=no,width=195,height=245,resizable=0,top="+cnTop+",left="+cnLeft);
docCal=cal.document;
change();
}

September 9, 2009 at 5:47 PM

continue....

function change()
{
var vCalHeader;
var vCalData;
var vCalTime;
var i;
var j;
var SelectStr;
var vDayCount=0;
var vFirstDay;

docCal.open();
docCal.writeln("<html><head><title>"+WindowTitle+"</title>");
docCal.writeln("<script>var winMain=window.opener;</script>");
docCal.writeln("</head><body background='"+ThemeBg+"' link="+FontColor+" vlink="+FontColor+"><form name='Calendar'>");

vCalHeader="<table border=1 cellpadding=1 cellspacing=1 width='100%' align=\"center\" valign=\"top\">\n";
vCalHeader+="<tr>\n<td colspan='7'><table border=0 width='100%' cellpadding=0 cellspacing=0><tr><td align='left'>\n";
vCalHeader+="<select name=\"MonthSelector\" onChange=\"javascript:winMain.Cal.SwitchMth(this.selectedIndex);winMain.change();\">\n";
for (i=0;i<12;i++)
{
if (i==Cal.Month)
SelectStr="Selected";
else
SelectStr="";
vCalHeader+="<option "+SelectStr+" value >"+MonthName[i]+"\n";
}
vCalHeader+="</select></td>";

vCalHeader+="\n<td align='right'><a href=\"javascript:winMain.Cal.DecYear();winMain.change()\"><b><font color=\""+YrSelColor+"\"><</font></b></a><font face=\"Verdana\" color=\""+YrSelColor+"\" size=2><b> "+Cal.Year+" </b></font><a href=\"javascript:winMain.Cal.IncYear();winMain.change()\"><b><font color=\""+YrSelColor+"\">></font></b></a></td></tr></table></td>\n";
vCalHeader+="</tr>";

if (ShowMonthYear)
vCalHeader+="<tr><td colspan='7'><font face='Verdana' size='2' align='center'><b>"+Cal.GetMonthName(ShowLongMonth)+" "+Cal.Year+"</b></font></td></tr>\n";


for (i=0;i<7;i++)
{
vCalHeader+="<td align='center'><font face='Verdana' size='2'>"+WeekDayName[i].substr(0,WeekChar)+"</font></td>";
}
vCalHeader+="</tr>";
docCal.write(vCalHeader);


CalDate=new Date(Cal.Year,Cal.Month);
CalDate.setDate(1);
vFirstDay=CalDate.getDay();
vCalData="<tr>";
for (i=0;i<vFirstDay;i++)
{
vCalData=vCalData+generateCell();
vDayCount=vDayCount+1;
}
for (j=1;j<=Cal.GetMonDays();j++)
{
var strCell;
vDayCount=vDayCount+1;
if ((j==todayDate.getDate())&&(Cal.Month==todayDate.getMonth())&&(Cal.Year==todayDate.getFullYear()))
strCell=generateCell(j,true,TodayColor);
else
{
if (j==Cal.Date)
{
strCell=generateCell(j,true,SelDateColor);
}
else
{
if (vDayCount%7==0)
strCell=generateCell(j,false,SaturdayColor);
else if ((vDayCount+6)%7==0)
strCell=generateCell(j,false,SundayColor);
else
strCell=generateCell(j,null,WeekDayColor);
}
}
vCalData=vCalData+strCell;

if((vDayCount%7==0)&&(j<Cal.GetMonDays()))
{
vCalData=vCalData+"</tr>\n<tr>";
}
}
docCal.writeln(vCalData);
docCal.writeln("\n</table>");
docCal.writeln("</form></body></html>");
docCal.close();
}

September 9, 2009 at 5:47 PM

continue..........

function generateCell(pValue,pHighLight,pColor){
var PValue;
var PCellStr;
var vColor;
var vHLstr1;
var vHlstr2;
var vTimeStr;

if (pValue==null)
PValue="";
else
PValue=pValue;

if (pColor!=null)
vColor="bgcolor=\""+pColor+"\"";
else
vColor="";
if ((pHighLight!=null)&&(pHighLight))
{vHLstr1="color='red'><b>";vHLstr2="</b>";}
else
{vHLstr1=">";vHLstr2="";}

if (Cal.ShowTime)
{
vTimeStr="winMain.document.getElementById('"+Cal.Ctrl+"').value+=' '";
if (TimeMode==12)
vTimeStr+="+' '+winMain.Cal.AMorPM";
}
else
vTimeStr="";
PCellStr="<td "+vColor+" width="+CellWidth+" align='center'><font face='verdana' size='2'"+vHLstr1+"<a href=\"javascript:winMain.document.getElementById('"+Cal.Ctrl+"').value='"+Cal.dateFormat(PValue)+"';"+vTimeStr+";window.close();\">"+PValue+"</a>"+vHLstr2+"</font></td>";
return PCellStr;
}

function Calendar(pDate,pCtrl){

this.Date=pDate.getDate();
this.Month=pDate.getMonth();
this.Year=pDate.getFullYear();
this.Hours=pDate.getHours();
this.MyWindow=cal;
this.Ctrl=pCtrl;
this.Format="ddMMyyyy";
this.Separator=DateSeparator;
}

function GetMonthIndex(shortMonthName)
{
for (i=0;i<12;i++)
{
if (MonthName[i].substring(0,3).toUpperCase()==shortMonthName.toUpperCase())
{ return i;}
}
}
Calendar.prototype.GetMonthIndex=GetMonthIndex;

function IncYear()
{ Cal.Year++;}
Calendar.prototype.IncYear=IncYear;

function DecYear()
{ Cal.Year--;}
Calendar.prototype.DecYear=DecYear;

function SwitchMth(intMth)
{ Cal.Month=intMth;}
Calendar.prototype.SwitchMth=SwitchMth;
function GetMonthName(IsLong)
{
var Month=MonthName[this.Month];
if (IsLong)
return Month;
else
return Month.substr(0,3);
}
Calendar.prototype.GetMonthName=GetMonthName;

function GetMonDays()
{
var DaysInMonth=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (this.IsLeapYear())
{
DaysInMonth[1]=29;
}
return DaysInMonth[this.Month];
}
Calendar.prototype.GetMonDays=GetMonDays;

function IsLeapYear()
{
if ((this.Year%4)==0)
{
if ((this.Year%100==0) && (this.Year%400)!=0)
{
return false;
}
else
{
return true;
}
}
else
{
return false;
}
}
Calendar.prototype.IsLeapYear=IsLeapYear;

function dateFormat(pDate)
{
if (this.Format.toUpperCase()=="DDMMYYYY")
return (pDate+DateSeparator+(this.Month+1)+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="DDMMMYYYY")
return (pDate+DateSeparator+this.GetMonthName(false)+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="MMDDYYYY")
return ((this.Month+1)+DateSeparator+pDate+DateSeparator+this.Year);
else if (this.Format.toUpperCase()=="MMMDDYYYY")
return (this.GetMonthName(false)+DateSeparator+pDate+DateSeparator+this.Year);
}
Calendar.prototype.dateFormat=dateFormat;

Thanks









Related Tutorials/Questions & Answers:
Hi,
Hi,  Hi,what is the purpose of hash table
Hi,
Hi,   labels = new Hashtable<Integer,JLabel>
Advertisements
Hi..
Hi..   what are the keywords available in simple HelloWorld program
Hi..
Hi..  what are access specifier available in java
HI.
HI.  hi,plz send me the code for me using search button bind the data from data base in dropdownlist
Hi..
Hi..  null is a keyword.True/False?   hi friend, In Java true, false and null are not a Java keyword they are literals in Java. For reading in detail go through the following link The null keyword
hi,
hi,  print("code sample");how to display all elements in 2d array usin any one loop
Hi
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
Hi
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me
hi....
hi....  plzz sent me d code for counting vowels in a string... gui programme
Hi
Hi   how to read collection obj from jsp to servlet and from jsp - jsp?   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://www.roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
Hi
Hi  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
hi....
hi....  a programme which displays a combobox which contains num from 1 to 10 and calculates the factorial of dt num which user clicks
hi
hi   I have connected mysql with jsp in linux and i have used JDBC connectivity but when i run the program, its not working the program is displaying
hi
hi   'print("code sample");`class example(){ public.static.void.main(); system.out.println("this is first pro");}   class example{ public static void main(String[]args){ System.out.println("this is first pro
Hi
Hi  Hi All, I am new to roseindia. I want to learn struts. I do not know anything in struts. What exactly is struts and where do we use it. Please help me. Thanks in advance. Regards, Deepak
Hi..
Hi..  diff between syntax and signature?   signature is a particular identity of a method in terms of its argument order ,type and their number e.g. void A(arguments) then here the order ,type and number of arguments
hi!
hi!  how can i write aprogram in java by using scanner when asking user to enter element user will be free to enter any type that he/she wants to to enter, like(int,double,float,String,....) thanx for answering....   Hi
hi
hi  int A[]=new int{2,5,4,1,3}; what is the error in declaration of this   Hi Friend, This is the wrong way of declaring an array.ADS_TO_REPLACE_1 Array is always declared in the following ways: 1)int arr[]=new int[5
hi
hi  what is the code for printing stars as follows * * * * * * * * * *print("code sample");   Hi Friend, Try... num=4; int p = num; int q = 0; for (int i = 0; i <= num; i++) { for (int j
hi
online multiple choice examination  hi i am developing online multiple choice examination for that i want to store questions,four options,correct answer in a xml file using jsp or java?can any one help me?   Please
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
Hi..
Hi..  what are the steps mandatory to develop a simple java program?   To develop a Java program following steps must be followed by a Java developer : First of all the JDK (Java Development Kit) must be available
Hi
Hi   I need some help I've got my java code and am having difficulty to spot what errors there are is someone able to help import java.util.Scanner; public class Post { public static void main(String[] args) { Scanner sc
hi.......
hi.......  i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design... for such a programme... plz help me...   Hi Friend, Try this: import java.awt.
hi!
hi!  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin"); } catch(Exception e
Hi
Hi   I have got this code but am not totally understanding what the errors. Could someone Please help. Thanks in advance! import java.util.Random; import java.util.Scanner; private static int nextInt() { public class
hi
hi   i want to develop a online bit by bit examination process as part of my project in this i am stuck at how to store multiple choice questions options and correct option for the question.this is the first project i am doing
hi
storing data in xml file using jsp  hi i am storing data in xml file using jsp.in this when i enter data into xml file i am getting xml declaration for each specified data?can any one help me to prevent this?   <
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=windows-1252"%> <html> <head> <meta http-equiv
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read that image file, we cant read that file.it return -1. and my console message
hi.......
hi.......  import java.awt.; import java.sql.*; import javax.swing.*; import java.awt.event.* public class NewJFrame extends javax.swing.JFrame...){ } } can anyone tell wts wrong with this code??   Hi, Check it: import
HI!!!!!!!!!!!!!!!!!!!!!
HI!!!!!!!!!!!!!!!!!!!!!  import java.awt.*; import java.sql.*; import javax.swing.*; import java.awt.event.*; public class NewJFrame extends...;Hi Friend, Try this: import java.awt.*; import java.sql.*; import javax.swing.
hi
hi
hi
hi
hi

Ads