![]() |
Clearing a select box after form submit. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Clearing a select box after form submit. (/showthread.php?tid=1111) |
Clearing a select box after form submit. - BrandenM - 02-12-2015 Code: <select class="form-control" id="project_type" name="project_type"> I have a select box that I am dynamically creating options for with php and repopulating the input with CI's set_select(). Everything works as expected but when I try to clear the form, the repopulated option acts as the selectedIndex ( as it should ) and I can't reset the input to the top option. I've tried a couple solutions with jQuery but had no luck. Has any one else ran into this issue? if so how did you handle it? RE: Clearing a select box after form submit. - mwhitney - 02-13-2015 In jQuery, you would just use $('#project_type').prop('selectedIndex', 0); RE: Clearing a select box after form submit. - RobertSF - 02-13-2015 (02-12-2015, 06:46 AM)BrandenM Wrote: when I try to clear the form, the repopulated option acts as the selectedIndex ( as it should ) and I can't reset the input to the top option.I think I had a problem similar to that, and I solved it this way. PHP Code: <select name="gift_list]"> |