Passing data from dropdown to array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Passing data from dropdown to array (/showthread.php?tid=44102) |
Passing data from dropdown to array - El Forum - 08-03-2011 [eluser]Michal1[/eluser] Hello, I am trying to pass a selected value from dropdown to array but I always get a value 0 even it should be char. I have a dropdown in view: Code: <?php echo form_dropdown('categories', $options, 'first_cat'); ?> Then in controller I am trying to get selected value from this dropdown and pass into: Code: function add_values() Then I have of course a code in model for inserting data into db. But it does not work. Am I doing something wrong? Passing data from dropdown to array - El Forum - 08-03-2011 [eluser]Pedro Luz[/eluser] change: Code: 'categories=>$this->input->post('categories') to: Code: 'categories'=>$this->input->post('categories') Passing data from dropdown to array - El Forum - 08-03-2011 [eluser]Michal1[/eluser] Ah sorry I of course have it like that. I just copied that here wrong. So what may be the real problem? Passing data from dropdown to array - El Forum - 08-03-2011 [eluser]LuckyFella73[/eluser] Can we see your model code too? Maybe the error can be found there. An other option would be that there is a problem with your $options array building the select/dropdown. Did you check the parsed sourcecode in your browser to get sure that you have the values set up right? |