-2

I want to load multiple partials inside a specific div. The amount of partials is given through by the user. Example: whenever a user want to buy traintickets, he needs to specify how many passengers will go with him. When the number of passengers had been chosen, new partials (passenger info forms),need to be loaded. If user selects 5 passenger, 5 partials need to be loaded dynamically. This is my existing code, but it isn't working: (to give you an idea)

$("#numberofpassengers").change(function() {
        var strNumb = $('#numberofpassengers').val().toString();
        var intNumb = parseInt(strNumb);

        for (var i = 1; i < intNumb; i++) {
            Html.Partial("_PassengerForm");
        }
    });

example

  • 1
    So what's your question? – mason Apr 18 '17 at 16:50
  • "Without AJAX" would mean that you'd post a form to do this. Or perhaps render the content dynamically from some JavaScript logic. So... Have you? Where are you stuck? – David Apr 18 '17 at 16:52
  • @David I have a partial view based on a viewmodel and I can only load 1 viewmodel. Can't "stack" them beneath each other if u know what I mean. – Edward Lamote Apr 19 '17 at 17:31

1 Answers1

0

Typically you would want to load that content dynamically.

If you don't want to load dynamically you could load all of it on the page and then just toggle the visibility of a given div based on the user's selection of the drop down.

Avitus
  • 15,640
  • 6
  • 43
  • 53