I want the user to be able to generate new input fields by the click of a button given a situation where the user would want to add additional information. It should also be possible to pass the amount of input fields to generate.
@{
Func<int, object> genInput =@<div class="generated">
@{
for (int i = 0; i < item; i++)
{
<input id="generatedInput[@i]" />
}
}
</div>;
@genInput(4);
<input id="amount" type="text" placeholder="Number of inputs to create"/>
<input type="button" onclick="genInput" />
}
I have created the function, but I don't know how to call it using the button or how to pass the amount of inputs to generate from the amount input along with it.
