• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Passing values from dropdown to an array as one

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


I would rather have something like this

'date'=>$this->input->post(alldropdown values..or something like that)

Or is there any better view hot to handle dropdowns with date?

Thank you

[eluser]Derek Allard[/eluser]
<select name="selection_date[days]">...days...</select>
<select name="selection_date[months]">...months...</select>
<select name="selection_date[years]">...years...</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!

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?

jQuery datepicker, generally.

Just a small correction to Derek's post, HTML arrays don't use quotes:

<select name="selection_date[day]">...</select>
<select name="selection_date[month]">...</select>
<select name="selection_date[year]">...</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.

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

    $(function() {
        $( "#to_them" ).datepicker();

<div class="demo">

<p> &lt;input id="to_them" type="text"&gt;&lt;/p>

</div>&lt;!-- End demo --&gt;

and id one of my controller functions I have

$data = array(

However it always receives an 0. Why is that? Thx

I don't see any form, but input values are passed via the 'name' attribute

&lt;input type="text" name="from_them" id="from_them"/&gt;

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.