Title: Cloning a section of a form? Post by: joe on June 19, 2017, 03:38:05 PM How do you properly clone a section of a form? I need to clone the "section" dynamically and then populate it with data from a database. I need to be able to assign incremental ids to all cloned fields/sections.
Here is how I declare the form: Code: <form id="ff" method="post"> Title: Re: Cloning a section of a form? Post by: qianet on June 22, 2017, 08:02:39 PM For reference only:
function AddXiangLine() { var count=parseInt($("#XiangCodeCount").val()); var rowID=parseInt(count/3)+1; var format=" <input id=\"BKC_XiangCodeThisNo\" name=\"BKC_XiangCodeThisNo\" " + " class=\"easyui-combobox\" "+ " data-options=\"editable:false,label:'Contianer Type',labelAlign:'right',labelWidth:80,width:'18%',required:false,height:32,valueField:'USER_DEFINED_TYPE',textField:'USER_DEFINED_TYPE',value:''\"/>"+ " <input id=\"BKC_XiangCountThisNo\" name=\"BKC_XiangCountThisNo\" "+ " class=\"easyui-numberspinner\" "+ " data-options=\"label:'Container Count',labelAlign:'right',labelWidth:40,width:'14%',height:30,editable:true,required:true,value:0,min:0,max:999\"/>"; var outStr=[]; outStr.push("<div class=\"row\" id=\"div_"+rowID+"\">"); outStr.push(myString.replace(format,"ThisNo",count+1)); var str2=myString.replace(format,"ThisNo",count+2); str2=myString.replace(str2,"labelWidth:80","labelWidth:87"); outStr.push(str2); var str3=myString.replace(format,"ThisNo",count+3); str3=myString.replace(str3,"labelWidth:80","labelWidth:95"); outStr.push(str3); outStr.push("</div>") $("#XiangCodeRow1").after(outStr.join("\n")); //解析easyui组件 $.parser.parse("#div_"+rowID); //Fill Container Type Data var data=$("#BKC_XiangCode1").combobox("getData"); data.push({USER_DEFINED_TYPE:""}); if(data.length>0) { $("#BKC_XiangCode"+(count+1)).combobox("loadData",data); $("#BKC_XiangCode"+(count+1)).combobox("setText","=Select="); $("#BKC_XiangCode"+(count+2)).combobox("loadData",data); $("#BKC_XiangCode"+(count+2)).combobox("setText","=Select="); $("#BKC_XiangCode"+(count+3)).combobox("loadData",data); $("#BKC_XiangCode"+(count+3)).combobox("setText","=Select="); } $("#XiangCodeCount").val(count+3); $("#delXiangBtn").linkbutton('enable'); } |