<SELECT>
<Option value = "" selected> </option>
.....
</SELECT>
<Textarea name, cols, rows> </textarea>
<Input name = "" type = "" maxlength = "" size = "" (width) value = "">
Text Box, password box, hidden, single choice, multiple choice box.
<Input type = "text" password, hidden, sumbit
Checkbox checked
The methods for getting the value are
Request. getparmeter ("name ");
Collect drop-down box attributes. Select, Option
The text has no border. When the label is used, the table is displayed and hidden.
<Input name, type = "text" disbled/readonly, class = "noborder" value = "Text to be displayed"
Size = "15" onclick = table1.style. Display = block/NONE>;
There are two places to write JS:
Between 1 <SCRIPT> </SCRIPT>
<Body onload = "javascript: window. setTimeout ('window. Close (), 5000 ')">
Or omit <body onload = "window. setTimeout ('window. Close (), 5000 ')">
Common Methods of window Mirroring
Alert .....
Window. open (); pop-up window in general, showmodaldialog (); webpage dialog box
SetTimeout ();
Parent window
Window. Opener
Window. opener. Location. Reload (); refresh
Calendar
Where you want to use the calendar Control
<Input class = input2 id = overtime onclick = "loadcalendar (this )"
Maxlength = 10 size = 11 name = overtime>
On the same page
Function loadcalendar (field ){
VaR RTN = Window. showmodaldialog ("calendar. JSP "," "," dialogwidth: 290px; dialogheight: 250px; Status: No; help: No; scrolling = no; scrollbars = No ");
If (RTN! = NULL)
Field. value = RTN;
Return;
}
Under the same level directory
Calendar. jsp
<% @ Page contenttype = "text/html; charset = gb2312" Language = "Java" %>
<HTML>
<Head>
<Title> date selector </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Style>
Body, TD {font-size: 9pt ;}
Input
{
Color: 333333;
Font-size: 9pt;
Border-width: 0;
Padding: 2;
Width: 20;
}
</Style>
</Head>
<Script language = JavaScript>
<! --
VaR monthnames = new array ("", "1", "2", "3", "4", "5", "6", "7 ", "8", "9", "10", "11", "12 ");
VaR endday = new array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31 );
VaR daynow = 0;
VaR monthnow = 0;
VaR yearnow = 0;
Function load (form ){
Set_month_year_now ();
VaR found = false;
For (VAR month = 0; month <form. monthlist. length; month ++)
If (Form. monthlist [month]. Text = monthnames [monthnow]) {
Form. monthlist [month]. Selected = true;
Found = true;
}
If (! Found ){
Error ();
Return;
}
VaR found = false;
For (VAR year = 0; year <form. yearlist. length; year ++)
If (Form. yearlist [year]. Text = yearnow ){
Form. yearlist [year]. Selected = true;
Found = true;
}
If (! Found ){
Error ();
Return;
}
Display_month (form );
}
Function preceding_month (form ){
VaR month_selected = form. monthlist. selectedindex;
VaR year_selected = form. yearlist. selectedindex;
If (! Month_selected &&! Year_selected ){
Error ();
Return;
}
If (month_selected> 0)
Month_selected --;
Else {
Month_selected = 11;
Year_selected --;
}
Form. monthlist [month_selected]. Selected = true;
Form. yearlist [year_selected]. Selected = true;
Display_month (form );
}
Function following_month (form ){
VaR month_selected = form. monthlist. selectedindex;
VaR year_selected = form. yearlist. selectedindex;
If (month_selected> = (Form. monthlist. Length-1) & year_selected> = (Form. yearlist. Length-1 )){
Error ();
Return;
}
If (month_selected <11)
Month_selected ++;
Else {
Month_selected = 0;
Year_selected ++;
}
Form. monthlist [month_selected]. Selected = true;
Form. yearlist [year_selected]. Selected = true;
Display_month (form );
}
Function set_month_year_now (){
VaR form = Document. calendar;
VaR now = new date ();
Monthnow = now. getmonth () + 1;
Yearnow = now. getyear ();
Daynow = now. getdate ();
Yearnow = (yearnow <100 )? Yearnow + 1900: yearnow;
VaR COUNT = 0
For (VAR I = yearNow-103; I <yearnow + 50; I ++ ){
Eval ("form. yearlist. Options [count] = New Option ('" + I + "', '" + I + "')");
Count ++;
}
Form. yearlist. selectedindex = 103;
Form. yearlist. Length = count;
}
Function error (){
Alert ("out of range! ");
}
Function display_month (form ){
VaR month = form. monthlist. selectedindex + 1;
VaR year = parseint (Form. yearlist. Options [Form. yearlist. selectedindex]. Text );
VaR start_day = start_day_in_month (year, month );
VaR COUNT = 0;
For (var row = 0; row <6; row ++ ){
For (VAR Col = 0; Col <7; Col ++)
{
If (ROW = 0 & Col <(start_day-1 ))
VaR day = "";
Else if (count <endday [month])
Day = ++ count;
Else
Day = "";
Form. daybox [(row * 7) + Col]. style. Display = "";
Form. daybox [(row * 7) + Col]. style. color = "black ";
If (Day = ""){
Form. daybox [(row * 7) + Col]. style. Display = "NONE ";
} Else {
Form. daybox [(row * 7) + Col]. value = Day;
If (COL % 7 = 0) form. daybox [(row * 7) + Col]. style. color = "red ";
If (yearnow = year & monthnow = month & daynow = day) form. daybox [(row * 7) + Col]. style. color = "blue ";;
}
}
}
}
Function start_day_in_month (year, month ){
VaR day, daynum, ndays, mnum;
SDAY = start_day_in_year (year );
Endday [2] = (Year % 4 )? 28: 29;
If (month = 1)
Daynum = SDAY;
Else {
Ndays = SDAY;
For (mnum = 2; mnum <month + 1; mnum ++)
Ndays = ndays + endday [mnum-1];
Daynum = ndays % 7;
}
Daynum = (! Daynum )? 7: daynum;
Return (daynum );
}
Function start_day_in_year (year ){
Var y, M, D;
VaR N;
Y = year-1; M = 13; D = 1;
N = d + 2 * m + (math. Floor (0.6 + (m + 1) + y );
N = N + math. floor (y/4)-math. floor (y/100) + math. floor (y/400) + 2;
N = math. Floor (n/7-math. Floor (n/7) * 7 + 0.5 ));
Return (n + 1 );
}
Function checkdate (strday ){
VaR docfrm = Document. calendar;
VaR choice_daynum = 0;
VaR current_daynum = 0;
VaR day_temp;
If (strday! = ""){
VaR stry = docfrm. yearlist. value;
VaR STRM = docfrm. monthlist. value;
VaR curr_y = new string (yearnow );
VaR curr_m = new string (monthnow );
VaR curr_d = new string (daynow );
If (curr_m.length = 1) curr_m = "0" + curr_m;
If (curr_d.length = 1) curr_d = "0" + curr_d;
Current_daynum = new number (curr_y + curr_m + curr_d );
If (STRM. Length = 1) STRM = "0" + STRM;
If (strday. Length = 1) strday = "0" + strday;
Choice_daynum = new number (stry + STRM + strday );
Parent. Window. returnvalue = stry + "-" + STRM + "-" + strday; // pass the selected date to the parent window.
Parent. Window. Close ();
}
Return false;
}
-->
</SCRIPT>
<Body onload = "load (document. calendar)" topmargin = "0">
<Center>
<Form name = "calendar">
<Table border = "0" cellpadding = "0" cellspacing = "0">
<Tr>
<TD colspan = "3" Height = "24"> </TD>
</Tr>
<Tr>
<TD width = "205" nowrap = "nowrap" align = "right"> <select name = "yearlist" onchange = "display_month (this. Form)">
</SELECT>
</TD>
<TD width = "65" nowrap = "nowrap" align = "Left"> <select name = "monthlist" size = "1" onchange = "display_month (this. form) ">
<% For (INT I = 1; I <13; I ++) {%>
<Option value = "<% = I %>"> <% = I %> </option>
<% }%>
</SELECT>
</TD>
<TD width = "10"> </TD>
</Tr>
<Tr>
<TD colspan = "3" Height = "6"> </TD>
</Tr>
<Tr>
<TD colspan = "3"> <Table border = "0" cellpadding = "1" cellspacing = "0" align = "center">
<Tr>
<TD bgcolor = "# 82664f"> <Table border = "0" cellpadding = "0" cellspacing = "0">
<Tr bgcolor = "# 82664f" Height = "18">
<TD width = "31" align = "center" nowrap = "nowrap"> <font color = "# ff0000"> day </font> </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 1 </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 2 </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 3 </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 4 </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 5 </TD>
<TD width = "31" align = "center" nowrap = "nowrap"> 6 </TD>
</Tr>
<% For (INT r = 0; r <6; r ++) {%>
<Tr bgcolor = "# ffffff" Height = "18">
<% For (int d = 0; D <7; D ++) {%>
<TD align = "center"> <input type = "text" size = "2" name = "daybox" readonly onclick = "javascript: checkdate (this. value); "onmouseover =" this. style. background = '# eeeeeee' "onmouseout =" this. style. background = 'white' ">
</TD>
<% }%>
</Tr>
<% }%>
</Table> </TD>
</Tr>
</Table> </TD>
</Tr>
</Table>
</Form>
</Center>
</Body>
</Html>