• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    javascript做的日歷,完全對象化,望高手提出改進意見。(3/3,將3部分拼成一個html文件瀏覽)

    發布: 2007-6-30 18:56 | 作者: admin | 來源: | 查看: 14次 | 進入軟件測試論壇討論

    領測軟件測試網   this.CreateMonthGrid = function(theYear, theMonth, theDay){ //refresh the month view to the date, main action is run this.setDayList() and set this.Source.value
        var theTextObject = this.Source;
        if (theTextObject == null){
          return;
        }
        var theName = this.Name;
        var theYearObject = document.all.item(theName + "_YearList");
        var theMonthObject = document.all.item(theName + "_MonthList");
        var tmpYear = theYear;
        var tmpMonth = theMonth;
        var tmpDay = 1;
        if (tmpMonth < 0){
          tmpYear--;
          tmpMonth = 11;
        }
        if (tmpMonth > 11){
          tmpYear++;
          tmpMonth = 0;
        }
        if (tmpYear < this.MinYear){
          tmpYear = this.MinYear;
        }
        if (tmpYear > this.MaxYear){
          tmpYear = this.MaxYear;
        }
        if (theDay < 1){
          tmpDay = 1;
        }else{
          tmpDay = this.GetMonthDays(tmpYear, tmpMonth);
          if (theDay < tmpDay){
            tmpDay = theDay;
          }
        }
        theYearObject.value = tmpYear;
        theMonthObject.value = tmpMonth;
        this.setDayList(tmpYear, tmpMonth, tmpDay);
        theTextObject.value = this.SetDateFormat(tmpYear, tmpMonth, tmpDay);
        theTextObject.select();
      }
      this.UpdateMonthGrid = function(theObject){ //run this.CreateMonthGrid() by theObject
        var theTextObject = this.Source;
        if (theTextObject == null){
          return;
        }
        var theName = this.Name;
        var theYearObject = document.all.item(theName + "_YearList");
        var theMonthObject = document.all.item(theName + "_MonthList");
        var theDayObject = document.all.item(theName + "_DayList");
        var tmpName = theObject.id.substr(theObject.id.lastIndexOf("_"));
        switch (tmpName){
          case "_goPreviousMonth": //go previous month button
            theObject.disabled = true;
            this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) - 1, parseInt(theDayObject.value, 10));
            theObject.disabled = false;
            break;
          case "_goNextMonth": //go next month button
            theObject.disabled = true;
            this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) + 1, parseInt(theDayObject.value, 10));
            theObject.disabled = false;
            break;
          case "_YearList": //year list
            this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10));
            break;
          case "_MonthList": //month list
            this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10));
            break;
          default:
            return;
        }
      }
      this.DeleteMonthGrid = function( ){ //check document focus, if blur this.Source then delete this
        var theName = this.Name;
        var theDivObject = document.all.item(theName + "_MonthView");
        if (theDivObject == null){
          return;
        }
        var tmpObject = document.activeElement;
        while (tmpObject != null){
          if (tmpObject == this.Source){
            return;
          }
          //if (tmpObject.id == theName + "_MonthView"){
          //  return;
          //}
          //if (tmpObject.id == theName + "_MonthGrid"){
          //  return;
          //}
          if (tmpObject.id == theName + "_goPreviousMonth"){
            return;
          }
          if (tmpObject.id == theName + "_goNextMonth"){
            return;
          }
          if (tmpObject.id == theName + "_YearList"){
            return;
          }
          if (tmpObject.id == theName + "_MonthList"){
            return;
          }    
          if (tmpObject.id == theName + "_DayList"){
            return;
          }
          tmpObject = tmpObject.parentElement;
        }
        if (tmpObject == null){ //delete the month view
          theDivObject.outerHTML = "";
          var theDate = new Date(this.GetTextDate(this.Source.value));
          if (isNaN(theDate)){
            this.Source.value = "";
          }else{
            this.Source.value = this.SetDateFormat(theDate.getFullYear(), theDate.getMonth(), theDate.getDate());
          }
          this.Source = null;
        }
      }
      this.InitialMonthView = function( ){
        var theName = this.Name;
        var theValue = this.Source.value;
        var theCurrentDate = new Date(this.GetTextDate(theValue));
        if (isNaN(theCurrentDate)){
          theCurrentDate = new Date();
        }
        var theDivHTML = "<div id=\"" + theName + "_MonthView\" onBlur=\"document.jsMonthView.DeleteMonthGrid();\">";
        theDivHTML += "    <table width=\"" + this.Width.toString() + "\" height=\"" + this.Height.toString() + "\" style=\"" + this.MonthGridStyle + "\" cellpadding=\"0\" cellspacing=\"0\">";
        theDivHTML += "      <tr>";
        theDivHTML += "        <td align=\"center\" valign=\"top\">";
        theDivHTML += "          <table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
        theDivHTML += "            <tr align=\"center\" style=\"" + this.HeaderStyle + "\">";
        theDivHTML += "              <td>";
        theDivHTML += "                <input type=\"button\" tabIndex=\"-1\" style=\"" + this.MonthBtStyle + "\" id=\"" + theName + "_goPreviousMonth\" value=\"" + this.PreviousMonthText + "\" onClick=\"document.jsMonthView.UpdateMonthGrid(this)\" onBlur=\"document.jsMonthView.DeleteMonthGrid()\">";
        theDivHTML += "              </td>";
        theDivHTML += "              <td>";
        theDivHTML += "                <select id=\"" + theName + "_MonthList\">";
        theDivHTML += "                </select>";
        theDivHTML += "              </td>";
        theDivHTML += "              <td>";
        theDivHTML += "                <select id=\"" + theName + "_YearList\">";
        theDivHTML += "                </select>";
        theDivHTML += "                <input type=\"hidden\" id=\"" + theName + "_DayList\" value=\"1\">";
        theDivHTML += "              </td>";
        theDivHTML += "              <td>";
        theDivHTML += "                <input type=\"button\" tabIndex=\"-1\" style=\"" + this.MonthBtStyle + "\" id=\"" + theName + "_goNextMonth\" value=\"" + this.NextMonthText + "\" onClick=\"document.jsMonthView.UpdateMonthGrid(this)\" onBlur=\"document.jsMonthView.DeleteMonthGrid()\">";
        theDivHTML += "              </td>";
        theDivHTML += "            </tr>";
        theDivHTML += "            <tr>";
        theDivHTML += "              <td colspan=\"4\" bgcolor=\"" + this.UnselectBgColor + "\">";
        theDivHTML += "                <div id=\"" + theName + "_MonthGrid\"><br></div>";
        theDivHTML += "              </td>";
        theDivHTML += "            </tr>";
        theDivHTML += "          </table>";
        theDivHTML += "        </td>";
        theDivHTML += "      </tr>";
        theDivHTML += "    </table>";
        theDivHTML += "  </div>";
        document.body.insertAdjacentHTML("beforeEnd", theDivHTML);
        theDivObject = document.all.item(theName + "_MonthView");
        theDivObject.style.position = "absolute";
        theDivObject.style.posLeft = this.GetoffsetLeft(this.Source);
        theDivObject.style.posTop = this.GetoffsetTop(this.Source) + this.Source.offsetHeight;
        this.CreateYearList(this.MinYear, this.MaxYear);
        this.CreateMonthList();
        this.CreateMonthGrid(theCurrentDate.getFullYear(), theCurrentDate.getMonth(), theCurrentDate.getDate());
      }
    }
    function CreateMonthView(theTextObject){ //the month view create interface, fire at element@#s onFocus event
      if (theTextObject.readOnly == true){
        return;
      }
      if (document.jsMonthView != null){
        if (document.jsMonthView.Source == theTextObject){
          return;
        }else{
          document.jsMonthView.DeleteMonthGrid();
        }
      }
      document.jsMonthView = new DefineMonthView(theTextObject);
      //insert your code, change the month view propertiy
      //example:
      //  document.jsMonthView.DateFormat = "<MMM> <d>,<yyyy>";
      document.jsMonthView.InitialMonthView();
      theTextObject.select();
    }
    function DeleteMonthView(theTextObject){ //the month view delete interface, fire at element@#s onBlur event
      if (document.jsMonthView == null){
        return;
      }
      document.jsMonthView.DeleteMonthGrid();
      if (document.jsMonthView.Source == null){
        document.jsMonthView = null;
      }
    }
    //-->
    </SCRIPT>
    </HEAD>

    <BODY bgcolor="#FFFFFF" text="#000000">
    <FORM name="form1" method="post" action="">
      <INPUT type="text" name="textfield" style="position:@#absolute@#;left:@#300px@#;top:@#150px@#;" value=""
       onFocus="CreateMonthView(this)"
       onBlur="DeleteMonthView(this)">
      <INPUT type="text" name="textfield2" value=""
       onFocus="CreateMonthView(this)"
       onBlur="DeleteMonthView(this)">
      <INPUT type="button" name="Button" value="Show All Elements" onClick="ShowAllElements(document.forms[0])">
      <SCRIPT language="javascript">
        function ShowAllElements(theform){
          var i=0,HTML_Str;
          HTML_Str = "<table border=1><tr><td>Type</td><td>Name</td><td>Id</td><td>Value</td></tr>";
          for (i=0;i<theform.elements.length;i++){
            HTML_Str += "<tr>";
            HTML_Str += "<td>" + theform.elements[i].type + "</td>";
            HTML_Str += "<td>" + theform.elements[i].name + "</td>";
            HTML_Str += "<td>" + theform.elements[i].id + "</td>";
            HTML_Str += "<td>" + theform.elements[i].value + "</td>";
            HTML_Str += "</tr>";
          }
          debug.innerHTML = HTML_Str + "</table>";
        }
      </SCRIPT>
    </FORM>
    <DIV id="debug"></DIV>
    </BODY>
    </HTML>

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>