Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4022818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:31:23+00:00 2026-05-20T10:31:23+00:00

So I have a complex form for an IncomeDeclaration. Its going to display a

  • 0

So I have a complex form for an IncomeDeclaration.

Its going to display a textfield GrossIncome for each Activity that the IncomeDeclaration is related to… this all gets done on the server and works just fine…. the problem is. The User should also be able to add Activities on the fly.. through javascript… so when the user clicks on Add Activity a Dropdown and a textfield must be appended to the bottom the activities list… heres what Ive got so far

<tbody id="activities">
            @Html.EditorFor(model => model.income.EconomicActivityIncomeDeclarations)

            </tbody>
        </table>
        <a href="#" id="add_activity">Agregar Otra Actividad</a>

    </fieldset>

    <script type="text/javascript">
        $("#add_activity").click(function () {

            $.getJSON('/IncomeDeclarations/GetEconomicActivities', function (data) {
                var select = new Select();
                var data = new Array();

                for (var i = 0; i < data.length; i++) {
                    var option = new Option(data[i]["name"], data[i]["i"])
                    //should do something here
                }


                //should call the template and append to #activities
            });
        });
</script>


    <script id="template" type="text/x-jquery-tmpl">
    <tr>
        <td><select name="income.EconomicActivityIncomeDeclarations[${SomeNumber}].EconomicActivityId">
        ${MyOptions}        
        </select></td>
        <td><input type="text" name="income.EconomicActivityIncomeDeclarations[${SomeNumber}].GrossIncome" /></td>>
    </tr>
</script>

}

The name attribute for both the select and the text_field is key for this to work… otherwise modelbinding wont work… I would think that if the SomeNumber variable is set to new Date.GetTime() model Binding should work just fine…

I actually dont see the need of ajax for this but thats another topic.. I just havent figured out a way to do this without ajax…
right now I want to get the template to work and append the form elements to the bottom of the list.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:31:24+00:00Added an answer on May 20, 2026 at 10:31 am

    See this
    http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm have a fair complex Form that I am trying to create in Play
I have a complex form that has a static section and one that can
I have a complex form for a model Schedule that belongs to a parent
Well i have a complex form view model like this : public class TransactionFormViewModel
I have a quite complex form that presents an option to run a script
I have a text_area in a partial in a complex form that is called
I have a rather complex model that I am using to render a form
I have two very complex queries that are displayed on the same form and
I have a complex form It allows the user to create an IncomeDeclaration which
I would like to have a complex form that uses various VBA script files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.