


Smarty internal date function html_select_date() usage example analysis, select function usage_PHP tutorial
Smarty internal date function html_select_date() usage example analysis, select function usage
This article describes the usage of smarty internal date function html_select_date() with examples. Share it with everyone for your reference. The details are as follows:
Main attributes:
prefix //string type The default prefix is "Date_"
start_year //string type defaults to the current year and can still be expressed in (/-N) mode. For example, start_year="-10" option starts from 1998
end_year //string type defaults to the same as above and can be expressed in (/-N) mode. For example, end_year=" 5" option will end in 2013
field_order //string type Default MDY is arranged in the order of month, day and year select
month_format //String type Default %B means January, February, etc. The %b format is an abbreviation and displays the first three letters of the month
//%m format is a digital display month
day_format //string type default d number represents from 01 to 31 and is not associated with the month %b format is binary display format rarely used
Other attributes:
display_days //boolean type controls whether the day selection is displayed
display_months //boolean type controls whether the month selection is displayed
display_years //boolean type controls whether the year selection is displayed
year_as_text //boolean type true is displayed as text type year false is displayed as drop-down menu type
reverse_years //boolean type, if true, the years are displayed in reverse order
Year_size // The string type value is controlled by the drop -down dish output 0 or 1 when the value is greater than 1 is controlled by the upper and lower arrows
month_size //Same as above
day_size //Same as above
An example is as follows:
Copy code The code is as follows: {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>
Please debug other attributes by yourself. The disadvantage of this date processing function is that day and month are not related. It is better to use js to process
The function that displays day in js can be defined as follows:
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; } } }
I hope this article will be helpful to everyone’s smarty-based PHP programming design.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
