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