Problem with form_dropdown fields - 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: Problem with form_dropdown fields (/showthread.php?tid=37181) |
Problem with form_dropdown fields - El Forum - 12-31-2010 [eluser]caperquy[/eluser] I am generating a drop-down field using form_dropdown. The result I get is something like this : <option value="0">January</option> <option value="1">February</option> <option value="2">March</option> The only problem I have is that when my controller receives the selected value, 1 for example, I do not know how to catch the string February which is associated with it. I thought that It might possible to generate something like <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> but I do not know how to do that. Many thanks to whoever can help. CapErquy Problem with form_dropdown fields - El Forum - 01-01-2011 [eluser]cLin[/eluser] Hrm, was searching google for this as well. Anyone know? Problem with form_dropdown fields - El Forum - 07-07-2011 [eluser]smilie[/eluser] Better late then never... My object $countries: Code: Array Code: foreach($countries as $key=>$val) Problem with form_dropdown fields - El Forum - 07-07-2011 [eluser]Unknown[/eluser] I just tried the code and still getting the same error. I wonder how to capture this with just simple coding. I know how to get this working but I need to code it like twice the lenght of the entire code. It involves complex algorithm but for sure this can be captured easily. Problem with form_dropdown fields - El Forum - 07-07-2011 [eluser]smilie[/eluser] what is 'same error'? My code, as stated above works as it should Show your code. Problem with form_dropdown fields - El Forum - 07-07-2011 [eluser]ccschmitz[/eluser] It uses the keys from the array you specify so make sure you are using an associate array, otherwise I think it will use numbers by default. Try this: Code: $options = array( |