Automatically extend years in static dropdown checkout forms using javascript

There are many ecommerce websites that have static coded checkout forms. For these forms, the code to populate the drop down lists for years may be hard coded, which presents longterm problems for your website. In cases where PHP or another suitable language is prohibited, you may be looking for a way to expand the year option of a field automatically.  If so, you can insert this javascript in in place of the hard coded <option>s, it will set the years options to be the current and go up to 10 in the future.

This solution works great with Adobe Business Catalyst projects, where the original eCommerce form has been manually over-written (for whatever reason).

<script type="text/javascript">

var d = new Date();
var curyr =d.getFullYear();
document.write('<option selected="true" value="'+curyr+'">'+curyr+'</option>');
document.write('<option value="'+cur+'">'+cur+'</option>');


Follow Ironpaper to receive new insights on B2B marketing and sales.

* Your privacy is important to us.

Ironpaper is a B2B marketing agency and lead generation agency. Ironpaper integrates design, technology and marketing for the web to drive meaningful results for clients. We are based in New York City and Charlotte, NC.