Create Multiple Dropdowns and get Values

I’m wanting to create a list of dropdowns based on an array and then get the values of the dropdowns.

So basically I have an array with numbers in it, and I want to create a dropdown for each number in that array, and then when I press submit, retrieve the value of each box.

Example

<select id="drop_64" name="drop_40">
    <option value="1">Value 1</option>
    <option value="2">Value 3</option>
    <option value="3">Value 4</option>
</select>
<select id="drop_12" name="drop_44">
    <option value="1">Value 1</option>
    <option value="2">Value 3</option>
    <option value="3">Value 4</option>
</select>

Then get the value for each box. The only problem is the array is never the same size every time, so it’s a different amount of dropdowns each time.

My array is a $_SESSION array. Example:

["prod"]=>
array(3) {
  ["ids"]=>
  array(2) {
    [0]=>
    string(2) "40"
    [1]=>
    string(2) "44"
  }
  ["newid"]=>
  array(2) {
    [0]=>
    string(0) ""
    [1]=>
    string(0) ""
  }
  ["newqty"]=>
  array(2) {
    [0]=>
    string(0) ""
    [1]=>
    string(0) ""
  }
}

So each dropdown box would be generated with the ID’s there

Not sure if I’ve explained this very well, so please let me know if you need any more info

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories