Input Date From Membership Signup Form

25 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 8, 2011   (RSS)

Re: [Jason] Input Date From Membership Signup Form

By Rusty - April 6, 2011 - edited: April 6, 2011

Hi Rusty,

You can try something like this:

Month:
<select name="month">
<?php foreach(range(1,12) as $month): ?>
<option value="<?php echo $month;?>"><?php echo date("F",strtotime("0000-$month"));?></option>
<?php endforeach ?>
</select>




Any particular reason that on CMSB v2.07 that the Month would be populating nothing but December as the Label?

<?php foreach(range(1,12) as $month): ?>
Option Value: <?php echo $month;?> - Descriptor: <?php echo date("F",strtotime("0000-$month"));?><br />
<?php endforeach ?>


Gives me this:
Option Value: 1 - Descriptor: December
Option Value: 2 - Descriptor: December
Option Value: 3 - Descriptor: December
Option Value: 4 - Descriptor: December
Option Value: 5 - Descriptor: December
Option Value: 6 - Descriptor: December
Option Value: 7 - Descriptor: December
Option Value: 8 - Descriptor: December
Option Value: 9 - Descriptor: December
Option Value: 10 - Descriptor: December
Option Value: 11 - Descriptor: December
Option Value: 12 - Descriptor: December


So I can tell the foreach is working properly, but for some reason it's displaying the month improperly.
Rusty

Re: [Rusty] Input Date From Membership Signup Form

By Jason - April 6, 2011

Hi Rusty,

I've found sometimes that the date function has trouble when you don't have leading zeros in front of numbers less than 10 (for example using 2 instead of 02).

Try something like this:

Month:
<select name="month">
<?php foreach(range(1,12) as $month): ?>
<?php if($month < 10) { $month = "0".$month; } ?>
<option value="<?php echo $month;?>"><?php echo date("F",strtotime("0000-$month"));?></option>
<?php endforeach ?>
</select>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Input Date From Membership Signup Form

By Rusty - April 8, 2011

Interesting, now the results simply give me the leading zero.

Option Value: 01 - Label: December
Option Value: 02 - Label: December
Option Value: 03 - Label: December
Option Value: 04 - Label: December
Option Value: 05 - Label: December
Option Value: 06 - Label: December
Option Value: 07 - Label: December
Option Value: 08 - Label: December
Option Value: 09 - Label: December
Option Value: 10 - Label: December
Option Value: 11 - Label: December
Option Value: 12 - Label: December


I wonder why the month in numeric form is working but the label isn't.
Rusty

Re: [Rusty] Input Date From Membership Signup Form

By robin - April 8, 2011

Hey Rusty,

The menu code above works for me, but different systems can treat the year "0000" differently. So here is a slightly modified version that should hopefully work to get your labels correct.

Month:
<select name="month">
<?php foreach(range(1,12) as $month): ?>
<?php if($month < 10) { $month = "0".$month; } ?>
<option value="<?php echo $month;?>"><?php echo date("F",strtotime("2010-" . $month . "-01"));?></option>
<?php endforeach ?>
</select>


Hope that helps,
Robin
Robin
Programmer
interactivetools.com