Welcome Guest, Not a member yet? Register   Sign In
Build Date Dropdown helper
#6

[eluser]stef25[/eluser]
im using egoslip's function as a helper after modifying the buildYearDropdown function slightly:

Code:
function buildYearDropdown($name='',$value='')
    {        
        $years = range(1900, date("Y"));
        foreach($years as $year)
        {
            $year_list[$year] = $year;
        }    
        
        return form_dropdown($name, $year_list, $value);
    }

called from controller with the 2nd parameter being the value that should be preselected in the drop down:

Code:
$data['dob_dropdown_year'] = buildYearDropdown('year', $data['old_profile_data']['year']);

and then printed out in the view via

Code:
<?= $dob_dropdown_year ?>


this generates a select field with name='year' and listing all years starting from 1900 till the current year and the values of the options are correct.

hope this helps some one!


Messages In This Thread
Build Date Dropdown helper - by El Forum - 07-10-2009, 04:58 AM
Build Date Dropdown helper - by El Forum - 07-10-2009, 08:45 AM
Build Date Dropdown helper - by El Forum - 07-10-2009, 12:25 PM
Build Date Dropdown helper - by El Forum - 07-14-2009, 03:08 PM
Build Date Dropdown helper - by El Forum - 07-15-2009, 01:09 PM
Build Date Dropdown helper - by El Forum - 08-02-2009, 12:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB