Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dob dropdown list from the latest years down..


Dennis_gull

Recommended Posts

Hey, I use a dropdown menu for dob but I would like it to set the latest year (now) first and not the other way around but I cant seem to get it to work. This is how the code looks like now:

$today = getdate();
	$first_year = $today['year'] - 77; 
	$last_year = $today['year'] - 14;
	for ($i=$first_year; $i < $last_year; $i++) {
		$dob_year_arr[] = array('id' => sprintf('%02d', $i), 'text' => sprintf('%02d', $i));
	}

(thats the year part of the code)

 

I wish I could just change the < to > but it doesnt allow me too :angry:

Link to comment
Share on other sites

  • 6 months later...

if (ACCOUNT_DOB == 'true') {

?>

<tr>

<td class="main"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>

<td class="main"><?php

 

$months = array(array('id' => '01', 'text' => MONTH_JANUARY), array('id' => '02', 'text' => MONTH_FEBRUARY),

array('id' => '03', 'text' => MONTH_MARCH), array('id' => '04', 'text' => MONTH_APRIL), array('id' => '05', 'text' => MONTH_MAY), array('id' => '06', 'text' => MONTH_JUNE), array('id' => '07', 'text' => MONTH_JULY), array('id' => '08', 'text' => MONTH_AUGUST), array('id' => '09', 'text' => MONTH_SEPTEMBER), array('id' => '10', 'text' => MONTH_OCTOBER), array('id' => '11', 'text' => MONTH_NOVEMBER), array('id' => '12', 'text' => MONTH_DECEMBER));

 

$days = array(array('id' => '01', 'text' => '1'),array('id' => '02', 'text' => '2'),

array('id' => '03', 'text' => '3'), array('id' => '04', 'text' => '4'), array('id' => '05', 'text' => '5'), array('id' => '06', 'text' => '6'), array('id' => '07', 'text' => '7'), array('id' => '08', 'text' => '8'), array('id' => '09', 'text' => '9'), array('id' => '10' , 'text' => '10'), array('id' => '11', 'text' => '11'), array('id' => '12', 'text' => '12'), array('id' => '13', 'text' => '13'), array('id' => '14', 'text' => '14'), array('id' => '15', 'text' => '15'), array('id' => '16', 'text' => '16'), array('id' => '17', 'text' => '17'), array('id' => '18', 'text' => '18'), array('id' => '19', 'text' => '19'), array('id' => '20', 'text' => '20'), array('id' => '21', 'text' => '21'), array('id' => '22', 'text' => '22'), array('id' => '23', 'text' => '23'), array('id' => '24', 'text' => '24'), array('id' => '25', 'text' => '25'), array('id' => '26', 'text' => '26'), array('id' => '27', 'text' => '27'), array('id' => '28', 'text' => '28'), array('id' => '29', 'text' => '29'), array('id' => '30', 'text' => '30'), array('id' => '31', 'text' => '31'));

 

/*This Will Make the Years Descend (To disable this and enable the other erase the following end statement */

for ($i=date("Y"); $i>=1920; $i--)

{

$years[] = array('id' => $i, 'text' => $i);

}

/*This will Make the Years Descend*/

 

 

/*This will Make the Years Ascend (To enable this add an end statement like this */ /*at the end of this line

 

for($i=1920; $i<date('Y')-10; $i++)

{

$years[] = array('id' => $i, 'text' => $i);

}

/*This will Make the Years Ascend*/

 

echo tep_draw_pull_down_menu('dob_month', $months);

echo tep_draw_pull_down_menu('dob_day', $days);

echo tep_draw_pull_down_menu('dob_year', $years);

echo ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': ''); ?></td>

</tr>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...