开发者

Automate Date Of Birth select element

When making a contact form in html/PHP (either) its a pain to sit there and type out all days, months and years into the select element. Is there a for loop or anything that can speed this process up, anything to avoid hardcoding this every开发者_如何学运维time?


for days:

<?php
$days = range(1, 31);
?>

for months:

<?php
$months = range(1, 12);
?>

for years:

<?php
$years = range(1930, date('Y'));
?>

EDIT:
And use it like that:

<select name="day">
<?php
foreach($days as $day) {
?>
  <option value="<?php echo($day) ?>"><?php echo($day) ?></option>
<?
}
?>
</select>

and so on ... ;-)


How about a jQuery driven date picker?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜