Welcome Guest, Not a member yet? Register   Sign In
Repopulate a Dropdown
#1

[eluser]digitaldivaradio[/eluser]
I have two drop down menus that are a simple arrays, occupations and states. This is a new user reg form. Both drop downs are required when the user submits the form.

When the user submits and fails validation all my text fields are repopulating, but not the drop-downs. I would like to make it easier on the user. Can you help me find the right way to repopulate a drop down?

Here is my code.


VIEW

Code:
$occupation = array(
    '' => 'SELECT YOUR OCCUPATION:',
    '1' => 'Architect / Designer',
    '2' => 'Landscape Architect / Designer',
    '3' => 'Commercial Contractor',
);
<?php        
    echo form_label('Occupation: <span class="requiredinfo">*</span>', 'occupation');
    echo form_dropdown('occupation', $occupation, '');

?&gt;

CONTROLLER

Code:
$this->form_validation->set_rules('occupation', 'Occupation', 'trim|required');

if ($this->form_validation->run() == FALSE)
{
    $this->signup();
}


Messages In This Thread
Repopulate a Dropdown - by El Forum - 06-08-2010, 08:54 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:17 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:31 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 10:48 AM
Repopulate a Dropdown - by El Forum - 06-08-2010, 11:39 AM
Repopulate a Dropdown - by El Forum - 02-08-2011, 07:47 PM
Repopulate a Dropdown - by El Forum - 06-20-2011, 04:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB