Welcome Guest, Not a member yet? Register   Sign In
get value of selected dropdown list????
#7

[eluser]andrewtheandroid[/eluser]
may i suggest storing $city as an array with $cities = array('id'=>'name');

Or if you need to store information other than name instead of name you could have an array

$cities = array('id'=>array('name'=>'paris','location'=>'france','population'=>'lots'));

Code:
<? foreach($cities as $id => $city_name){>

                 <option value="&lt;? echo $id;?&gt;">&lt;? echo $city_name;?&gt;</option>
            
            &lt;?}?&gt;

               // OR if you used the second option
               foreach ($cities as $id => $properties)
               {
                   echo '<option value="'.$id.'">'.$properties['name'].'</option>';
               }

&& here is the controller
Code:
// here i need to make echo for selected value of city dropdown list.
$id = $this->input->post('city'); // The value will be the id array index

// to display the one you want
$selected_city = $cities['id'];
// OR second option
$selected_city = $cities['id']['name'];


Messages In This Thread
get value of selected dropdown list???? - by El Forum - 11-13-2009, 04:18 PM
get value of selected dropdown list???? - by El Forum - 11-13-2009, 05:09 PM
get value of selected dropdown list???? - by El Forum - 11-15-2009, 05:52 AM
get value of selected dropdown list???? - by El Forum - 11-15-2009, 02:22 PM
get value of selected dropdown list???? - by El Forum - 11-17-2009, 10:24 AM
get value of selected dropdown list???? - by El Forum - 11-17-2009, 11:29 AM
get value of selected dropdown list???? - by El Forum - 11-17-2009, 05:57 PM
get value of selected dropdown list???? - by El Forum - 11-17-2009, 06:30 PM
get value of selected dropdown list???? - by El Forum - 07-14-2012, 03:29 AM
get value of selected dropdown list???? - by El Forum - 07-14-2012, 11:57 AM
get value of selected dropdown list???? - by El Forum - 07-14-2012, 10:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB