<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="javascript">
var str = "";
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\">");
str += "\u65f6<select id=\"_hour\">";
for (h = 0; h <= 9; h++) {
    str += "<option value=\"0" + h + "\">0" + h + "</option>";
}
for (h = 10; h <= 23; h++) {
    str += "<option value=\"" + h + "\">" + h + "</option>";
}
str += "</select> \u5206<select id=\"_minute\">";
for (m = 0; m <= 9; m++) {
    str += "<option value=\"0" + m + "\">0" + m + "</option>";
}
for (m = 10; m <= 59; m++) {
    str += "<option value=\"" + m + "\">" + m + "</option>";
}
str += "</select> \u79d2<select id=\"_second\">";
for (s = 0; s <= 9; s++) {
    str += "<option value=\"0" + s + "\">0" + s + "</option>";
}
for (s = 10; s <= 59; s++) {
    str += "<option value=\"" + s + "\">" + s + "</option>";
}
str += "</select> <input name=\"queding\" type=\"button\" onclick=\"_select()\" value=\"\u786e\u5b9a\" style=\"font-size:12px\" /></div>";
document.writeln(str);
var _fieldname;
function _SetTime(tt) {
    _fieldname = tt;
    var ttop = tt.offsetTop;    //TT控件的定位点高
    var thei = tt.clientHeight;    //TT控件本身的高
    var tleft = tt.offsetLeft;    //TT控件的定位点宽
    while (tt = tt.offsetParent) {
        ttop += tt.offsetTop;
        tleft += tt.offsetLeft;
    }
    document.getElementById("_contents").style.top = ttop + thei + 4;
    document.getElementById("_contents").style.left = tleft;
    document.getElementById("_contents").style.visibility = "visible";
}
function _select() {
    _fieldname.value = document.getElementById("_hour").value + ":" + document.getElementById("_minute").value + ":" + document.getElementById("_second").value;
    document.getElementById("_contents").style.visibility = "hidden";
}</script>
<body>
<input type="text" name="textfield" onclick="_SetTime(this)"/>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>
    <script language="javascript">
    var str = "";
    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\">");
    str += "年<select id=\"_year\">";
    for (y = 1900; y <= 2012; y++) {
        str += "<option value=\"" + y + "\">" + y + "</option>";
    }
    str += "</select> 月<select id=\"_mon\">";
    for (m = 1; m <= 12; m++) {
    if (m<10)
        str += "<option value=\"0" + m + "\">0" + m + "</option>";
    else
        str += "<option value=\"" + m + "\">" + m + "</option>";
    }
    str += "</select> 日<select id=\"_date\">";
    for (d = 1; d <= 31; d++) {
    if (d<10)
        str += "<option value=\"0" + d + "\">0" + d + "</option>";
    else
        str += "<option value=\"" + d + "\">" + d + "</option>";
    }
    str += "</select> ";
    str += "\u65f6<select id=\"_hour\">";
    for (h = 0; h <= 9; h++) {
        str += "<option value=\"0" + h + "\">0" + h + "</option>";
    }
    for (h = 10; h <= 23; h++) {
        str += "<option value=\"" + h + "\">" + h + "</option>";
    }
    str += "</select> \u5206<select id=\"_minute\">";
    for (m = 0; m <= 9; m++) {
        str += "<option value=\"0" + m + "\">0" + m + "</option>";
    }
    for (m = 10; m <= 59; m++) {
        str += "<option value=\"" + m + "\">" + m + "</option>";
    }
    str += "</select> \u79d2<select id=\"_second\">";
    for (s = 0; s <= 9; s++) {
        str += "<option value=\"0" + s + "\">0" + s + "</option>";
    }
    for (s = 10; s <= 59; s++) {
        str += "<option value=\"" + s + "\">" + s + "</option>";
    }
    str += "</select> <input name=\"queding\" type=\"button\" onclick=\"_select()\" value=\"\u786e\u5b9a\" style=\"font-size:12px\" /></div>";
    document.writeln(str);
    var _fieldname;
    function _SetTime(tt) {
        _fieldname = tt;
        var ttop = tt.offsetTop;    //TT控件的定位点高
        var thei = tt.clientHeight;    //TT控件本身的高
        var tleft = tt.offsetLeft;    //TT控件的定位点宽
        while (tt = tt.offsetParent) {
            ttop += tt.offsetTop;
            tleft += tt.offsetLeft;
        }
        document.getElementById("_contents").style.top = ttop + thei + 4;
        document.getElementById("_contents").style.left = tleft;
        document.getElementById("_contents").style.visibility = "visible";
    }
    function _select() {
        _fieldname.value = document.getElementById("_year").value + "." + document.getElementById("_mon").value + "." + document.getElementById("_date").value + " " + document.getElementById("_hour").value + ":" + document.getElementById("_minute").value + ":" + document.getElementById("_second").value;
        document.getElementById("_contents").style.visibility = "hidden";
    }</script>
    <body>
    <input type="text" name="textfield" onclick="_SetTime(this)"/>
    </body>
    </html>