Skip to content

Dynamic Year Dropdown List

Last updated on October 7, 2014

Here is a snippet of PHP code to create a dynamic Dropdown form field which contain years in the Dropdown List.

we can achieve this in so many ways but i am gonna show you most simplest one here.By using PHP’s built in function range(), we can create an array of years see the below example how i used range() function.

Example :

Function to Generate dropdown list Dynamically

';
        foreach( $r as $year )
        {
            $select .= "

How to use


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
*/?>
0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments