添加完成后,把表单代码改成如下代码即可
<script type="text/javascript"> function LoadLineEditor(id) { KindEditor.create('#' + id, { autoHeightMode: true }); } function domvadd_line() { var i; var str=''; var oldi=0; var j=0; var addnum=0; addnum=parseInt(document.add.mvaddnum_line.value); oldi=parseInt(document.add.mveditnum_line.value); for(i=1;i<=addnum;i++) { j=i+oldi; str=str+'<tr><td width="11%" align="center">行程第<span style="color:red;">'+j+'</span>天安排</td><td width="89%" align="left"><input type="text" name="line_1[]" id="line_1_'+j+'" value="" size="100"></td></tr><tr><td width="11%" align="center" bgcolor="#FFFFFF">行程内容</td><td width="89%" align="left" bgcolor="#FFFFFF"><textarea data-name="textarea" name="line_2[]" id="line_2_'+j+'" style="width:680px; height:400px;"></textarea></td></tr><tr><td align="center" bgcolor="#FFFFFF">就餐安排</td><td align="left" bgcolor="#FFFFFF">早餐:<input type="text" name="line_3[]" id="line_3_'+j+'" value="" size="20">中餐:<input type="text" name="line_4[]" id="line_4_'+j+'" value="" size="20">晚餐:<input type="text" name="line_5[]" id="line_5_'+j+'" value="" size="20"></td></tr><tr><td align="center" bgcolor="#FFFFFF">住宿/车辆</td><td align="left" bgcolor="#FFFFFF">住宿:<input name="line_6[]" id="line_6_'+j+'" value="" size="30">车辆:<input name="line_7[]" id="line_7_'+j+'" value="" size="30"></td></tr>'; } $('#mvadd_line').html('<table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#DBEAF5">'+ str +'</table>'); $("[data-name=textarea]").each(function(){ LoadLineEditor($(this).attr('id')); }); } </script>
<table width="100%" border="0" cellspacing="1" cellpadding="1" > <tr> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5"> <tr> <td align="left">行程安排设置</td> </tr> </table></td> </tr> <tr> <td> <?php if($ecmsfirstpost==1) { ?> <table width='100%' border=0 cellspacing=1 cellpadding=3 bgcolor="#DBEAF5"> <?php $editnum=1; for($i=1;$i<=$editnum;$i++) { ?> <tr> <td width="11%" align="center">行程第<span style="color:red;"><?=$i?></span>天安排</td> <td width="89%" align="left"><input name="line_1_<?=$i?>" type="text" id="line_1_<?=$i?>" value="" size="100"></td> </tr> <tr> <td width="11%" align="center" bgcolor="#FFFFFF">行程内容</td> <td width="89%" align="left" bgcolor="#FFFFFF"><textarea name="line_2_<?=$i?>" id="line_2_<?=$i?>" style="width:680px; height:400px;"></textarea><script type="text/javascript">LoadLineEditor('line_2_<?=$i?>');</script></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">就餐安排</td> <td align="left" bgcolor="#FFFFFF">早餐: <input name="line_3_<?=$i?>" type="text" id="line_3_<?=$i?>" value="" size="20"> 中餐: <input name="line_4_<?=$i?>" type="text" id="line_4_<?=$i?>" value="" size="20"> 晚餐: <input name="line_5_<?=$i?>" type="text" id="line_5_<?=$i?>" value="" size="20"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">住宿/车辆</td> <td align="left" bgcolor="#FFFFFF">住宿: <input name="line_6_<?=$i?>" type="text" id="line_6_<?=$i?>" value="" size="30"> 车辆: <input name="line_7_<?=$i?>" type="text" id="line_7_<?=$i?>" value="" size="30"></td> </tr> <?php } ?> </table> <?php } else { $editnum=0; if($r['line']) { $r['line']=stripSlashes($r['line']); ?> <table width='100%' border=0 cellspacing=1 cellpadding=3 bgcolor="#DBEAF5"> <?php //录入项 $j=0; $mvf_record=explode('||||||',$r['line']); $mvf_count=count($mvf_record); for($i=0;$i<$mvf_count;$i++) { $j=$i+1; $mvf_field=explode("::::::",$mvf_record[$i]); ?> <tr> <td width="11%" align="center">行程第<span style="color:red;"><?=$j?></span>天安排</td> <td width="89%" align="left"><input name="line_1[]" type="text" id="line_1_<?=$j?>" value="<?=$mvf_field[0]?>" size="100"> <input type="hidden" name="line_mvid[]" id="line_mvid_<?=$j?>" value="<?=$j?>"> <input type="checkbox" name="line_mvdelid[]" id="line_mvdelid_<?=$j?>" value="<?=$j?>"> 删</td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">行程内容</td> <td align="left" bgcolor="#FFFFFF"><textarea name="line_2[]" id="line_2_<?=$j?>" style="width:680px; height:300px;"><?=$mvf_field[1]?></textarea> <script type="text/javascript">LoadLineEditor('line_2_<?=$j?>');</script></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">就餐安排</td> <td align="left" bgcolor="#FFFFFF">早餐: <input name="line_3[]" type="text" id="line_3_<?=$j?>" value="<?=$mvf_field[2]?>" size="20"> 中餐: <input name="line_4[]" type="text" id="line_4_<?=$j?>" value="<?=$mvf_field[3]?>" size="20"> 晚餐: <input name="line_5[]" type="text" id="line_5_<?=$j?>" value="<?=$mvf_field[4]?>" size="20"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">住宿/车辆</td> <td align="left" bgcolor="#FFFFFF">住宿: <input name="line_6[]" type="text" id="line_6_<?=$j?>" value="<?=$mvf_field[5]?>" size="30"> 车辆: <input name="line_7[]" type="text" id="line_7_<?=$j?>" value="<?=$mvf_field[6]?>" size="30"></td> </tr> <?php } ?> </table> <?php $editnum=$j; } } ?></td> </tr> <tr> <td id="mvadd_line"></td> </tr> <tr> <td height="25">增加行程安排: <input name="mveditnum_line" type="hidden" id="mveditnum_line" value="<?=$editnum?>"> <input name="mvnum_line" type="hidden" id="mvnum_line" value="7"> <input name="mvmust_line" type="hidden" id="mvmust_line" value="1"> <input name="mvaddnum_line" type="text" id="mvaddnum_line" value="1" size="6"> <input type="button" name="Submit5" value="输出" onclick="javascript:domvadd_line();"></td> </tr>
</table>
|