views:

45

answers:

1

I have a field with a 1:N relationship with some other fields. I need the user to specifier how many elements are related to that particular field to enable me create the right amount of controls dynamically through JavaScript of JQuery.

I dont want to have the user enter the data repeatedly.

How can i create these controls please?

A: 

One way is, you can have a div with some Id and access that div using jQuery and append the html of the control that you want to that div. (all your dynamic controls that you want to add can go into this div)

<div id="ControlsContainer"> </div> <!-- this is in the aspx page -->

In the java script, you can do something like this

var previousHtml = $("#ControlsContainer").html();
$("#ControlsContainer").html(previousHtml + "<input type='text' value='something'>");

Thanks

Mahesh Velaga
You may want to five the `<input>`s names, or they will not be posted to the server.
Kobi
It's '<input>' not `<input>`. I tried it.
Colour Blend
I am glad that it worked, but I am not able to understand the '<input>' part that above comments are talking about don't the "<input>" that I mentioned work ? I am just curious .. thanks :)
Mahesh Velaga