0
我使用一些附加形式的新数据,不存在在bootstrap 3模式中添加新的字段和克隆?
HTML
电话号码:
JS
$(document).ready(function(){
var phone_number_form_index=0;
$("#add_phone_number").click(function(){
phone_number_form_index++;
$(this).parent().before($("#phone_number_form").clone().attr("id","phone_number_form" + phone_number_form_index));
$("#phone_number_form" + phone_number_form_index).css("display","inline");
$("#phone_number_form" + phone_number_form_index + " :input").each(function(){
$(this).attr("name",$(this).attr("name") + phone_number_form_index);
$(this).attr("id",$(this).attr("id") + phone_number_form_index);
});
$("#remove_phone_number" + phone_number_form_index).click(function(){
$(this).closest("div").remove();
});
});
});
,这里是工作提琴
我试图添加到自举3模式,但我有没有运气,这里要说的是同样的代码在引导3模式
http://www.bootply.com/J9cv7EZv6K
是否可以扩展此exmaple喜欢选择,但我需要该数组的选择值
http://www.bootply.com/S9WGrK0WhL
这里是我的榜样,我需要的是
- PHONE_NUMBER1 成为 PHONE_NUMBER [1],
- 和qty1到成为数量[1]
这能更固定的$(this).attr(“name”,$(this).attr(“name”)+ ph one_number_form_index);变得像phone_number [1],所有其他元素可以在数组中,当提交时知道输入是在数组 – 2014-09-22 09:55:07
可以ypu请检查我的编辑? – 2014-09-22 10:02:03
@TanjaPakovic查看最新答案 – Manwal 2014-09-22 10:09:42