get value of selected dropdown list???? |
[eluser]amira_fcis[/eluser]
how to get the value of selected text from dropdown list that user select from a view and i get it from the controller....here is the view Code: <h5>City*</h5> && here is the controller Code: // here i need to make echo for selected value of city dropdown list. thanks for help
[eluser]amira_fcis[/eluser]
many thanks ,but what if i need the value of option like 1,2,3 depending on the selected item of course. Code: <option value="<? echo $ty['id'] ;?>"></option>
[eluser]amira_fcis[/eluser]
no this echo ids 1,2,3,.... i need values like London,Paris,....
[eluser]Cro_Crx[/eluser]
If you need the names of the cities instead of the ID's then simply set the names of the values. Code: <option value="<? echo $ci['name'] ;?>"><? echo $ci['name'];?></option>
[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){> && here is the controller Code: // here i need to make echo for selected value of city dropdown list.
[eluser]CI_avatar[/eluser]
Code: $selected_value = $this->input->post('city'); is the correct one. please check the values of your array.
[eluser]_Moat_[/eluser]
i know this is an old topic but i have a problem where the post is not retrieving the value of the selected option. what i'm doing is: VIEW: Code: <select name="ID"> CONTROLLER: Code: $selected_Val = $this->input->post('ID'); the value of the $selected_Val= 0 and it never changes if the the option changed.
[eluser]CroNiX[/eluser]
How many times are you going to ask the exact same question and ignore the solutions? You are not using set_value() correctly. It requires at least one parameter, the field name to get the value of. |
Welcome Guest, Not a member yet? Register Sign In |