HTML
<select name="select" id="select">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<br>
<input id="bla" type="text" name="attendant[]">
JQuery
$("select").change(function() {
var select = parseFloat($('#select').val());
$('#bla').after('<br><input id="bla" type="text" name="attendant[]">');
});
Hi guys, above is the code I created.
I need the select box on change to update the the number of form field base on the value of the select box. If user change to 4 there should be 4 form field display on screen. If value change to 1 there should only be one on the screen.
Not so good with JQuery just started few days ago so any help is appreciated.
Thanks
Here is the JSFiddle I’m working on.
http://jsfiddle.net/andrewvmail/b5Gqg/3/
Try this
HTML
Javascript
You can achieve the same without using
.clone().. That was unnecessary..Check Fiddle
Without clone