1
I would like to know how to create input fields according to the value I add in a field.
Ex: I have a number type field that has a minimum value of 1 the maximum value of 4 and the default value is 1:
<input type="number" min="1" max="4" value="1" />
Since the default value of the field is 1 an input field must be created, but if the user changes this value to 3 2 more fields must be created totaling 3 fields.
You can wait for the event
change
in that input of a numerical type. Based onvalue
of it, can make a loop to create the others inputs.– Renan Gomes
Where are the other inputs added? What type of input? The first is already added when the page loads or is created via Javascript?
– Sergio
@Sergio The first input is already created, the other inputs will be created on the same page and in the same form and will be text type.
– Dark Media
@Darkmedia ok, and how is the HTML of the first input? has some particular class to be able to find it in DOM?
– Sergio
@Sergio At first there is no class to find it but there is no problem in adding one. the HTML of the first input currently looks like this: <input type="text" class="form-control" id="ncamisa" name="ncamisa" placeholder="Shirt size(s)">
– Dark Media