form_dropdown issues - 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: form_dropdown issues (/showthread.php?tid=48772) |
form_dropdown issues - El Forum - 01-28-2012 [eluser]helmy[/eluser] I'm having issues figuring out how to dynamically set the selected value on my drop down box. Does anyone know of a good tutorial for using drop down boxes? form_dropdown issues - El Forum - 01-28-2012 [eluser]smilie[/eluser] It is all in the user guide: http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html "The first parameter will contain the name of the field, the second parameter will contain an associative array of options, and the third parameter will contain the value you wish to be selected." So just set as third param, dymically what you want to be pre-selected. Cheers, Smilie form_dropdown issues - El Forum - 01-28-2012 [eluser]helmy[/eluser] I've looked over the user guide and these forums several times. I'm sure it's something simple and I'm over looking it. I'm using drop down box to edit the position an item shows up in a menu. I want the current position the item is to be the selected value. Here's what I currently have in my code. Model: Code: ### View: Code: <p> Position: <?php echo form_dropdown('position', $page_count, /* Mystical 3rd param */); ?> </p> Controller: Code: function edit_page($sel_subject = NULL, $sel_page = NULL) { form_dropdown issues - El Forum - 01-28-2012 [eluser]helmy[/eluser] I figured it out. I used Code: $this->uri->segment(4) Thanks for your reply Smilie. |