Skip to content

Instantly share code, notes, and snippets.

@jnowland
Created July 23, 2013 06:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnowland/6060199 to your computer and use it in GitHub Desktop.
Save jnowland/6060199 to your computer and use it in GitHub Desktop.
Select boxes for birthday in freemember echos out bday_d , bday_m, bday_y for expression engine. Works with PHP on output.
<div class="control-group">
<label for="{pr_form_id}-date-of-birth">Date of Birth</label>
<select id="{embed:form_prefix}-bday_d" name="bday_d" class="dob-day">
<option value="">Day</option>
<?php for ($i=1; $i < 32; $i++) : ?>
<option value="<?php echo $i ?>"
<?php echo ($i == "{bday_d}") ? 'selected="selected"' : "" ?>
>
<?php echo $i ?></option>
<?php endfor; ?>
</select>
<select id="{embed:form_prefix}-bday_m" name="bday_m" class="dob-month">
<option value="">Month</option>
<?php foreach(array('January','February','March','April','May','June','July','August','September','October','November','December') as $k => $i) : ?>
<option
value="<?php echo ($k+1) ?>"
<?php echo (($k+1) == "{bday_m}") ? 'selected="selected"' : "" ?>
>
<?php echo $i ?>
</option>
<?php endforeach; ?>
</select>
<select id="{embed:form_prefix}-bday_y" name="bday_y" class="dob-year">
<option value="">Year</option>
<?php
$max_age = 100;
$min_age = 1;
$current = date('Y');
?>
<?php foreach (range($min_age,$max_age) as $year) : ?>
<option
value="<?php echo ($current - $year) ?>"
<?php echo (($current - $year) == "{bday_y}") ? ' selected="selected" ' : "" ?>
>
<?php echo ($current - $year) ?>
</option>
<?php endforeach; ?>
?>
</select>
</div>
@ZenitramPRO
Copy link

Will you include filter for leap year?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment