tags:

views:

201

answers:

3

Is it possible to have multiple drop down lists in asp.net mvc?

What I'm trying to do is have a drop down list, say with many colours, Red, Green, Blue, Black etc. Then next to it a text box which the user can enter a number.

However there should be then a small + little sign next to it so that another drop down list appears underneath it allowing the user to select another colour. The number of times they can add drop down boxes should ideally be unlimited. Is this possible? I know I can put hidden drop down lists underneath them then enable/show them when the user clicks the + button, but this will only mean a limited number of drop down lists!

Thanks

+1  A: 

This has nothing to do with ASP.net mvc. It is a pure JavaScript. Use jQuery to add ddl dynamically.

epitka
Thanks! I guess it can be done with jquery or javascript, didn't realise that, MVC will just bind it all into the controller anyhow no matter how many drop down list tags are created. More here for anyone wanting to do this, this example is a div tag: http://stackoverflow.com/questions/953415/how-to-dynamically-add-a-div-using-jquery
+1  A: 

Sure, you can add as many pull-down menus to your page as you like (and it sounds like you are comfortable with the scripting to do so). Just make sure to add a unique name to each of those menus so you can access the values in your controller.

JMP
A: 

you can add an ajax action link that will update a div with a drop down list and the same div. So you can add as many dropdown list you want.

Gregoire