您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關(guān)html_select_date()函數(shù)怎么在smarty中使用,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
主要屬性:
prefix //string類型 默認(rèn)前綴名為"Date_"
start_year //string類型 默認(rèn)為當(dāng)前年份 仍可以用(+/-N)模式表示 如start_year="-10" option就從1998年開始
end_year //string類型 默認(rèn)同上 可用(+/-N)模式表示 如end_year="+5" option就到2013為止
field_order //string類型 默認(rèn)MDY 即按月日年的順序 排放select
month_format //string類型 默認(rèn)%B 即顯示為January、February、etc. %b格式為簡寫形式 顯示月份的前三個(gè)字母
//%m格式為數(shù)字顯示月份
day_format //string類型 默認(rèn)%02d 數(shù)字表示從01~31 并且與月份不關(guān)聯(lián) %b格式為二進(jìn)制顯示格式 很少用
其他屬性:
display_days //boolean類型 控制day的select是否顯示
display_months //boolean類型 控制month的select是否顯示
display_years //boolean類型 控制year的select是否顯示
year_as_text //boolean類型 true顯示為text型年份 false顯示為下拉菜單型
reverse_years //boolean 類型 true的情況下年份為倒序顯示
year_size //string 類型 值在大于1的情況下均為下拉菜單型輸出 0或1時(shí)為上下箭頭控制
month_size //同上
day_size //同上
示例如下:
復(fù)制代碼 代碼如下:
{html_select_date prefix="StartDate" time=$time start_year="-5" end_year="+1" display_days=false}
OUTPUT: (current year is 2000)
<select name="StartDateMonth"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12" selected>December</option> </select> <select name="StartDateYear"> <option value="1999">1995</option> <option value="1999">1996</option> <option value="1999">1997</option> <option value="1999">1998</option> <option value="1999">1999</option> <option value="2000" selected>2000</option> <option value="2001">2001</option> </select>
其他的屬性,請自行調(diào)試。這個(gè)日期處理函數(shù)的缺點(diǎn)是day與month不關(guān)聯(lián),不如用js處理
其中js顯示day的函數(shù)可以如下定義:
function showdays(year,month){ var day="day"; if(month.value==0){ document.getElementById(day).length=1; return; }else{ if(month.value==1||month.value==3||month.value==5||month.value==7||month.value==8||month.value==10||month.value==12){ document.getElementById(day).length=1; createlist(1,32,day); return; }else if(month.value==2){ if(year.value%4==0&&year.value%100!=0||year.value%400==0){ document.getElementById(day).length=1; createlist(1,30,day); return; }else{ document.getElementById(day).length=1; createlist(1,29,day); return; } }else{ document.getElementById(day).length=1; createlist(1,31,day); return; } } }
看完上述內(nèi)容,你們對html_select_date()函數(shù)怎么在smarty中使用有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。