1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3 <html> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 6 <title>时分秒</title> 7 </head> 8 <script language="javascript"> 9 var str = ""; 10 document.writeln("<div id=\"_contents\" style=\"padding:6px; background-color:#E3E3E3; font-size: 12px; border: 1px solid #777777; position:absolute; left:?px; top:?px; width:?px; height:?px; z-index:1; visibility:hidden\">"); 11 str += "\u65f6<select id=\"_hour\">"; 12 for (h = 0; h <= 9; h++) { 13 str += "<option value=\"0" + h + "\">0" + h + "</option>"; 14 } 15 for (h = 10; h <= 23; h++) { 16 str += "<option value=\"" + h + "\">" + h + "</option>"; 17 } 18 str += "</select> \u5206<select id=\"_minute\">"; 19 for (m = 0; m <= 9; m++) { 20 str += "<option value=\"0" + m + "\">0" + m + "</option>"; 21 } 22 for (m = 10; m <= 59; m++) { 23 str += "<option value=\"" + m + "\">" + m + "</option>"; 24 } 25 str += "</select> \u79d2<select id=\"_second\">"; 26 for (s = 0; s <= 9; s++) { 27 str += "<option value=\"0" + s + "\">0" + s + "</option>"; 28 } 29 for (s = 10; s <= 59; s++) { 30 str += "<option value=\"" + s + "\">" + s + "</option>"; 31 } 32 str += "</select> <input name=\"queding\" type=\"button\" οnclick=\"_select()\" value=\"\u786e\u5b9a\" style=\"font-size:12px\" /></div>"; 33 document.writeln(str); 34 var _fieldname; 35 function _SetTime(tt) { 36 _fieldname = tt; 37 var ttop = tt.offsetTop; //TT控件的定位点高 38 var thei = tt.clientHeight; //TT控件本身的高 39 var tleft = tt.offsetLeft; //TT控件的定位点宽 40 while (tt = tt.offsetParent) { 41 ttop += tt.offsetTop; 42 tleft += tt.offsetLeft; 43 } 44 document.getElementById("_contents").style.top = ttop + thei + 4; 45 document.getElementById("_contents").style.left = tleft; 46 document.getElementById("_contents").style.visibility = "visible"; 47 } 48 function _select() { 49 _fieldname.value = document.getElementById("_hour").value + ":" + document.getElementById("_minute").value + ":" + document.getElementById("_second").value; 50 document.getElementById("_contents").style.visibility = "hidden"; 51 } 52 53 </script> 54 <body> 55 56 <input name="time" type="text" onclick="_SetTime(this)"/> 57 58 </body> 59 </html>