用window.showModalDialog打开一个页面就可以了。
把text当参数传进去。
页面里面有你要的东西,返回的时候把值赋给text.

解决方案 »

  1.   


    主界面:
    <br><INPUT type="text" name=text1  >
    <INPUT type="button" value="日期" name="pickDate"  onclick="aaa(this);">
    <br><INPUT type="text" name=text2>
    <INPUT type="button" value="时间" name="pickTime"  onclick="aaa(this);" >
    <br><INPUT type="text" name=text3>
    <INPUT type="button" value="时间日期" name="pickAll" onclick="aaa(this);"> <SCRIPT>
    function aaa(obj)
    {
    var para="scroll:no;status:no;center:yes;unadorned:no;dialogHeight:215px;dialogWidth:"
    switch (obj.name) 
    {
    case "pickDate" :
    //只选日期
            para+="450px;";
    case "pickTime" :
    //只选时间
    para+="200px;";
    break;
    case "pickAll" :
    //全选
    para+="450px;";
    break;
    }
    window.showModalDialog("time.htm?" ,obj, para)}</SCRIPT>
    文件二,时间选择器。
    <HTML>
    <HEAD> 
    <TITLE>时间选择器</TITLE>
    <style>
    body 
    {
    margin-left: 0px;
    margin-top: 10px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #d4d0c8;
    }
    input.txt

    BORDER-TOP: lightgrey 1px solid; 
    BORDER-LEFT: lightgrey 1px solid;
    BORDER-RIGHT:lightgrey 1px solid;
    BORDER-BOTTOM: lightgrey 1px solid; 
    BACKGROUND-COLOR: #d4d0c8;
     }
      input.btn {
    font-family: 宋体 Fixedsys; 
    font-size:12px;
    BORDER-RIGHT: royalblue 1px solid;
    BORDER-TOP: royalblue   1px solid;
    BORDER-LEFT: royalblue 1px solid;
    LINE-HEIGHT: 16px; 
    BORDER-BOTTOM: royalblue 1px solid; 
    HEIGHT: 18px;
    BACKGROUND-COLOR: lightblue; 
    cursor:hand;
    COLOR: royalblue; 
     }
    body,td {
    font-size: 12px;
    }
    .N
    {
    display:none;
    }
    .B
    {
    display:block;
    }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
    <BODY>
    <table width="98%" height="170"  border="1" align="center" cellpadding="0" cellspacing="0" >
      <tr>
        <td width="270" id=tdDate  >
          <OBJECT id=C1 height=170 width=270  onMouseMove="setDate();"
          classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02><PARAM NAME="_Version" VALUE="524288"><PARAM NAME="_ExtentX" VALUE="7144"><PARAM NAME="_ExtentY" VALUE="4498"><PARAM NAME="_StockProps" VALUE="1"><PARAM NAME="BackColor" VALUE="-2147483633"><PARAM NAME="Year" VALUE="2004"><PARAM NAME="Month" VALUE="4"><PARAM NAME="Day" VALUE="28"><PARAM NAME="DayLength" VALUE="0"><PARAM NAME="MonthLength" VALUE="0"><PARAM NAME="DayFontColor" VALUE="0"><PARAM NAME="FirstDay" VALUE="1"><PARAM NAME="GridCellEffect" VALUE="1"><PARAM NAME="GridFontColor" VALUE="10485760"><PARAM NAME="GridLinesColor" VALUE="-2147483632"><PARAM NAME="ShowDateSelectors" VALUE="-1"><PARAM NAME="ShowDays" VALUE="-1"><PARAM NAME="ShowHorizontalGrid" VALUE="-1"><PARAM NAME="ShowTitle" VALUE="-1"><PARAM NAME="ShowVerticalGrid" VALUE="-1"><PARAM NAME="TitleFontColor" VALUE="10485760"><PARAM NAME="ValueIsNull" VALUE="0"></OBJECT></td><td width="180" align="center" valign="middle">     
      
            <table width="100%"  border="0" cellpadding="0" cellspacing="0" id=tbTime>
            <tr>
              <td align="center" scope=row>系统时间 <span id=text1></span> </td>
            </tr>
            <tr>
              <td align="center" scope=row>设置时间:</td>
            </tr>
            <tr>
              <td align="center" scope=row><select id=s1 onchange="settime();"></select >点<select id=s2 onchange="settime();"></select>分<select id=s3 onchange="settime();"></select>秒</td>
            </tr>
            <tr>
              <td align="center" scope=row><input id="text2" ></td>
            </tr>
          </table>
            <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="tbDate">
              <tr>
                <td align="center" scope="row">日期: <br>
                <input  id="text3"></td>
              </tr>
            </table>
            <br>
        <input type="button" onClick="rtn();" value="确定"></td>
      </tr>
    </table>
    <br>
    <br>
    <SCRIPT>
    switch (window.dialogArguments.name) 
    {
    case "pickDate" :
            tbTime.className ="N";
            setDate();
            break;
    case "pickTime" :
    tbDate.className ="N";
    tdDate.className="N";
    iniTime();
    break;
    case "pickAll" :
    setDate();
    iniTime();} 
    function iniTime()
    {
    text1.innerText=getMyTime(); 
    addAll(s1,23);
    addAll(s2,59);
    addAll(s3,59);
    d = new Date();
    s1.selectedIndex=d.getHours();
    s2.selectedIndex=d.getMinutes();
    s3.selectedIndex=d.getSeconds();
    window.setInterval("text1.innerText=getMyTime();","1000");
    settime();
     }
    function getobj(obj)
    {
    for(i=1;i<obj.document.all.length;i++)
    {
    if(obj==obj.document.all(i))
    {
    return(obj.document.all(i-1))
    }
    }
    }
    function settime()
    {
    text2.value=s1.value+":"+s2.value+":"+s3.value;
    }
    function setDate()
    {
    if(text3.value != C1.Year + "-" + C1.Month + "-" + C1.Day)
    {
    text3.value=C1.Year + "-" + C1.Month + "-" + C1.Day;
    }
    }
    function rtn(obj)
    {
    var r=new String("");
    r=text3.value + " " + text2.value;
    r=r.replace(/(^[\s]*)|([\s]*$)/g, "");
    getobj(window.dialogArguments).value=r;
    self.close(); 
    }function getMyTime(){
       var d, s = "";
       var c = ":";
       d = new Date();
       s += d.getHours() + c;
       s += d.getMinutes() + c;
       s += d.getSeconds(); 
       return(s)  ;
    }
    function addAll(obj,n)
    {
    var ooo=document.createElement("<OPTION>");
    for(i=0;i<=n;i++)
    {
     add(obj,i,i);
    }
    }
    function add(obj,v,t)
    {
    var ooo=document.createElement("<OPTION>");
    ooo.value=v;
    ooo.text=t;
    obj.add(ooo);
    }
    </SCRIPT>
    </BODY>
    </HTML>
      

  2.   

    http://www.adr.gov.cn/download/panyuguang/timePicker.htm
    演示
      

  3.   

    使用的时候按钮要紧贴着text框后边,因为我是按照按钮前最后一个text标签传递返回值的。
      

  4.   

    把所有<PARAM>标记删除就会是当前日期了。
    我忘记删除了,那东西是开发工具自己加的。
      

  5.   

    若第一个页面这样写就更完美了:
    window.showModalDialog("time.htm?"+Math.random(),obj, para)
      

  6.   

    jackfruitgoat(二十一) 说的有道理!!
      

  7.   

    日期选择器在某些机器上显示不正常,原因可能是这些机器系统安装时候MSCAL.OCX这个文件丢失,如果是2000或者xp系统,他位于系统盘:\winnt\system32\目录下,那么把正常机器的该文件放到相应的地方,或者下栽http://www.adr.gov.cn/download/MSCAL.OCX放到相应的地方,然后点击开始----运行
    输入
    regsvr32 MSCAL.OCX 
    有什么反应?是不是告诉你success?
    再实验一下,ok?
    安装时候采用克隆的办法或者光盘磨损都可能造成虽然安装成功,但是个别不重要的文件丢失。
    还有某些游戏作弊程序也会修改系统时间相关的内容