Displaying month with for loop

<select autocomplete=”cc-exp-month” id=”mnth” name=”cd_month” data-validation=”required” data-validation-error-msg=” Credit Card Exp Month”>
<option value=””>Month</option>
<?php for($j=1;$j<13;$j++){ ?>
<option value=”<?php if(count(str_split($j)) == 1){ echo ‘0’.$j; }else{ echo $j; } ?>” <?php echo ($j==$this->input->post(‘cd_month’))?’selected=”selected”‘:”; ?>>
<?php if(count(str_split($j)) == 1){ echo ‘0’.$j; }else{ echo $j; } ?>
</option>
<?php } ?>
</select>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s