Passing values from dropdown to an array as one - 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 values from dropdown to an array as one (/showthread.php?tid=39145) |
Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]Michal1[/eluser] Hey guys, I am trying do a thing which will pass the values from 3 dropdowns to a one array. The reason why I am doing this is that. I have three dropdowns. First one contains numbers from 1-31 second one has 1-12 and the third one has 2009,2010,2011 Most of you now probably realised that those are like a date dropdowns. Now I have an array data and I want to insert into that selected values from all three dropdowns. Is that possible? Or do I need to create 3 fields in an array for each dropdown and have something like this Code: $data=array( I would rather have something like this code]$data=array( 'date'=>$this->input->post(alldropdown values..or something like that) ); [/code] Or is there any better view hot to handle dropdowns with date? Thank you Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]Derek Allard[/eluser] Code: <select name="selection_date[days]">...days...</select> Still thoguh, if it were me, and I was building 3 dropdowns, then I'd probably want to harvest them when they are submitted as 3 separate form fields. edit: removed quotes, thanks noctrum! Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]Michal1[/eluser] Ok thank you. And is there any better way how to work with date dropdown? I just basically want to have a dropdown where user can choose a day, month and year and then I would like to pass that date which he elected as a one to some array for example? Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]danmontgomery[/eluser] jQuery datepicker, generally. Just a small correction to Derek's post, HTML arrays don't use quotes: Code: <select name="selection_date[day]">...</select> This gives you what you're asking for, all 3 values in one array. If you have 3 dropdowns, you're going to have 3 values. Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]Michal1[/eluser] Thank you, so I am trying to use a jquery date picker. It seems great however I have a problem with passing data from it to array. I have this in my view Code: [removed] and id one of my controller functions I have Code: $data = array( However it always receives an 0. Why is that? Thx Passing values from dropdown to an array as one - El Forum - 03-02-2011 [eluser]danmontgomery[/eluser] I don't see any form, but input values are passed via the 'name' attribute Code: <input type="text" name="from_them" id="from_them"/> |