• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form_Dropdown with Blank "Select One..." Option

#4
[eluser]dhall[/eluser]
Here's an example.

Controller:

Code:
$data['gender_options'] = $this->dropdown_model->get_genders();

Model:

Code:
function get_genders()
  {
    $options = array (
      'male' => 'Male',
      'female' => 'Female'
    );
    return $options;
  }

View:

Code:
echo form_label('Gender: ').br(1);
echo form_dropdown('gender',$gender_options,$gender_answer);

So in html this shows:
Code:
<label>Gender: </label>
<br>
<select name="gender">
<option value="male">Male</option>
<option value="female">Female</option>
</select>

I want it to show:
Code:
<label>Gender: </label>
<br>
<select name="gender">
<option selected="selected" value="">Select One...</option>
<option value="male">Male</option>
<option value="female">Female</option>
</select>

And if they do not select one then it returns an error.


Messages In This Thread
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 03:08 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 04:19 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:01 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:07 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:11 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:12 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:14 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 05:27 AM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-07-2012, 09:36 PM
Form_Dropdown with Blank "Select One..." Option - by El Forum - 08-08-2012, 03:33 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.