How can form elements be repeated as many times as chosen by (the value of a) select box?
I tried to get the value from the select box and based on that integer value, the form should be repeated. For example in select box, selecting 2 means the form should display 2 times.
My html code is:
<select id="sel" class="sel">
<?php
$v=1;
while($v<=10){
?>
<option value="$v"> <?php echo $v; ?></option>
<?php $v++; } ?></select>
<button class="add_field_button">Add More Fields</button>
<div>name:<input type="text" name="mytext[]"></div>
</div>
<div id="inrlog" style="display:none;">
<div>name:<input type="text" name="selname"></div>
</div>
and my Javascript is:
$(document).ready(function() {
var e = document.getElementById("sel");
$("#sel").select(function(){
$("#sel").click(function(){
$("#inrlog").show("slow");
});
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…