Welcome Guest, Not a member yet? Register   Sign In
How to set a default value Dropdown approcach?
#6

[eluser]CroNiX[/eluser]
Just set it up before you create the rest of the entries in your loop. 1 extra line. I always use an id of 0 since autoincremented db fields start at 1 so it will never interfere with the real data, and then use 'is_natural_no_zero' for form validation if it is a required field.
Code:
function selcountry()
{
  $this->db->select('id,name');
  $query=$this->db->get('country');
  $data22=array(0 => '--Select--'); //just add the default with key of 0 before you populate the array
  foreach($query->result_array() as $row)
  {
   $data22[$row['id']]=$row['name'];
  }
  return ($data22);    
}


Messages In This Thread
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 04:53 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 05:08 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 05:20 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 06:28 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 06:55 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:22 AM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:06 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:11 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:27 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:30 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 09:39 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 10:13 PM
How to set a default value Dropdown approcach? - by El Forum - 03-21-2012, 10:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB