I've created a for loop that creates an amount of dropdown menu's depending on a variable. The options are coming from the database. Like this:
@for ($i = 0; $i< $variable; $i++)
<select name="name[]">
@for ($x = 0; $x< $variable2; $x++)
<option value={{$result[$x]->columname}}>something</option>
@endfor
</select>
@endfor
So basically when the $variable=3
there will be 3 dropdown menu's with the same options. Now whenever there are values in some dropdown menu's and the person clicks the button, I want the variables to stay in it. I know I can use selected
but I have no idea how to make sure it stays on the right option in the right dropdown menu.
Now whenever I var_dump('name');
I get to see all the option value's of the existing dropdown menu's in an array. So of course I send back the Input::get('name')
from the controller to the view like: return View::make('page')->with('name',Input::get('name'));
My question is, how would I actually be able to get the values to stay in the dropdown menu they were in before with the Input value I have right now?