February 25, 2014

Create select box month and year for payment form



<select id="expiration-month" name="payment[cc_exp_month]">
	<option value="">MM</option>
	<?php foreach (range(1,12) as $month): ?>
	<option value="<?php echo $month; ?>"><?php echo str_pad($month, 2, "0", STR_PAD_LEFT); ?></option>
	<?php endforeach; ?>
</select>

<select id="expiration-year" name="payment[cc_exp_year]">
	<option value="">YYYY</option>
	<?php foreach (range(date('Y'), date('Y') + 20) as $year): ?>
	<option value="<?php echo $year; ?>"><?php echo $year; ?></option>
	<?php endforeach; ?>
</select>
There was an error in this gadget