在bootstrap 3模式中添加新的文件和克隆
Add new filed and clone in bootstrap 3 modal?
我正在表单中使用一些不存在的附加新数据
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();
});
});
});
这是工作小提琴
http://jsfiddle.net/wc28f/3/
我正试图添加到bootstrap 3模式,但我没有运气,这是bootstrap 3模态中的相同代码
http://www.bootply.com/J9cv7EZv6K
确实可以扩展这个exmaple样的选择,但我需要的是选择值的后数组
http://www.bootply.com/S9WGrK0WhL
这是我的例子,我需要的是
- phone_ number1变为phone_
- qty1到变成数量[1]
工作演示
我已经删除了线路,它工作
$("#phone_number_form" + phone_number_form_index).css("display","inline");
使用此:
$("#phone_number_form" + phone_number_form_index).removeClass("hidden");
你想要phone_number[1]
试试这个:
$(this).attr("name",$(this).attr("name") +"["+ phone_number_form_index+"]");
更新的演示
相关文章:
- 如何将json文件添加到grunt构建中
- 如何将 JavaScript 和 CSS 文件添加到 MagentoModule
- 如何将jQuery文件添加到导航网站
- 将图像从文件添加到 HTML5 画布
- Drupal 7 将 jQuery 文件添加到所有页面
- 尝试将外部JS和CSS文件添加到我的rails应用程序中
- mongodb用户配置文件添加输入时出现问题
- 通过JSZip将文件添加到现有的zip存档中
- 如何避免为我的每个html文件添加ExpressJS app.get()
- 为文件添加下载选项
- javascript向文本文件添加/从中删除
- 将JavaScript文件添加到WordPress主题
- 将js文件添加到流星项目中
- jquery.filer编辑模式动态文件添加
- 使用javascript/jquery将外部文件添加到$_FILES数组中
- Joomla JS 文件添加
- 使用 spring 将 JS 文件添加到 JSP 文件时获得 404
- JavaScript JSzip将文件添加到每个循环
- 将本地 JavaScript 文件添加到页面
- 姜戈;在自定义小部件中向媒体文件添加变量