场景: 一年12其 下拉框 1-12 选择几就 产生几个input (需要新增 和修改)
function getstagedetatil(){ var stageinfo =$("#stageinfo").val(); var num=$("#stage").val(); $(".tr_stage").remove(); var html="<tr class='tr_stage'>"; if(typeof(stageinfo) != "undefined"&&stageinfo!=""){ $("#stageinfo").val(''); var str= new Array(); str=stageinfo.split(","); for (i=1;i<=str.length ;i++ ) { html+="<td class='tit'>分期详情:"+i+"</td><td><input type='text' name='stageinfo' htmlEscape='false' maxlength='255' value='"+str[i-1]+"' class='input-large ' /></td>"; if(i%2==0){ html+="</tr><tr class='tr_stage'>" } } }else{ for(var i=1;i<=num;i++){ html+="<td class='tit'>分期详情:"+i+"</td><td><input type='text' name='stageinfo' htmlEscape='false' maxlength='255' class='input-large ' /></td>"; if(i%2==0){ html+="</tr><tr class='tr_stage'>" } } } html+="</tr>" $("#stagedetail").after(html); }