[英]How to show multiple input fields using onchange function?
$(document).on("change","#noofpack",function(){
count = $(this).val();
for(i=1;i<=count;i++){
$("#packageDiv").html('<input type="text" class="form-control" name="unit_price[]" placeholder="Unit Price" required="">');
}
});
I want to show multiple input fields onchange noofpack
if count
is 3
then it must show three input fields but what happen here when I change noofpack
then it show only 1
input fields.如果
count
为3
,我想在 onchange noofpack
上显示多个输入字段,那么它必须显示三个输入字段,但是当我更改noofpack
时会发生什么,然后它只显示1
输入字段。 So, How can I do this?那么,我该怎么做呢? Please help me.
请帮我。
Thank You谢谢你
$(document).on("change","#noofpack",function(){
count = $(this).val();
$("#packageDiv").html(""); // First empty the packageDiv
for(i=1;i<=count;i++){
// Append more instead oh HTML
$("#packageDiv").append('<input type="text" class="form-control" name="unit_price[]" placeholder="Unit Price" required="">');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.