當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateField::DateField方法代碼示例

本文整理匯總了PHP中DateField::DateField方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateField::DateField方法的具體用法?PHP DateField::DateField怎麽用?PHP DateField::DateField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DateField的用法示例。


在下文中一共展示了DateField::DateField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: jsDateField

 /**
  * jsDateField::jsDateField()
  *
  * Constructor: create a new jsdatefield object
  *
  * @param object &$oForm: the form where the datefield is located on
  * @param string $sName: the name of the datefield
  * @param string $sMask:
  * @param boolean $bRequired:
  * @param string $sInterval:
  * @param boolean $bIncludeJS: do we include the js file
  * @return jsDateField
  * @author Teye Heimans
  */
 function jsDateField(&$oForm, $sName, $sMask = null, $bRequired = null, $sInterval = null, $bIncludeJS)
 {
     // call the constructor of the datefield
     parent::DateField($oForm, $sName, $sMask, $bRequired, $sInterval);
     // check if the mask contains all three fields..
     $str = $this->_getFieldsFromMask();
     // is the mask ok (can we use a js datefield ?
     $this->_isOk = strlen($str) == 3 && strpos($str, 'd') !== false && strpos($str, 'm') !== false && strpos($str, 'y') !== false;
     // when not OK, just return a datefield
     if (!$this->_isOk) {
         return;
     }
     static $bSetJS = false;
     // needed javascript included yet ?
     if (!$bSetJS) {
         $bSetJS = true;
         // add the needed javascript
         if ($bIncludeJS == true) {
             $oForm->_setJS(FH_FHTML_DIR . "js/calendar_popup.js", true);
             $oForm->_setJS("document.write(getCalendarStyles());\n" . "function getDateString( fldForm, fldYear, fldMonth, fldDay ) {\n" . "    var frm = document.getElementById(fldForm);\n" . "    var objY = frm.elements[fldYear];\n" . "    var objM = frm.elements[fldMonth];\n" . "    var objD = frm.elements[fldDay];\n" . "    var y    = objY.options[objY.selectedIndex].value;\n" . "    var m    = objM.options[objM.selectedIndex].value;\n" . "    var d    = objD.options[objD.selectedIndex].value;\n" . "    if (y=='' || m== '') { \n" . "        return null;\n" . "    }\n" . "    if (d=='') { \n" . "        d = 1;\n" . "    }\n" . "    return y+'-'+m+'-'+d;\n" . "}\n");
         }
     }
 }
開發者ID:jwiegel,項目名稱:FormHandler,代碼行數:37,代碼來源:class.jsDateField.php


注:本文中的DateField::DateField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。