미채택 완료

간단한 질문하나 드립니다

2018-08-22 (수) 10:30:11 2,562

3077114933_1534901051.6055.png

Copy
<thead>
            <tr>
              <th>요금제<span id="add_charge">+</span></th>
              <th>기본요금</th>
              <th>공시지원금</th>
              <th>신규가입</th>
              <th>번호이동</th>
              <th>기기변경</th>
              <th>데이터</th>
              <th>음성</th>
              <th>문자</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td><input type="text" name="it_11[1]" value="<?php echo $it_11[1] ?>"></td>
              <td><input type="text" name="it_11[2]" value="<?php echo $it_11[2] ?>"></td>
              <td><input type="text" name="it_11[3]" value="<?php echo $it_11[3] ?>"></td>
              <td><input type="text" name="it_11[4]" value="<?php echo $it_11[4] ?>"></td>
              <td><input type="text" name="it_11[5]" value="<?php echo $it_11[5] ?>"></td>
              <td><input type="text" name="it_11[6]" value="<?php echo $it_11[6] ?>"></td>
              <td><input type="text" name="it_11[7]" value="<?php echo $it_11[7] ?>"></td>
              <td><input type="text" name="it_11[8]" value="<?php echo $it_11[8] ?>"></td>
              <td><input type="text" name="it_11[9]" value="<?php echo $it_11[9] ?>"></td>
            </tr>
          </tbody>
Copy
<script>
            $(function(){
                $('#charge').on('click', 'span[id="add_charge"]', function() {
                    var $contents = $('#charge tr:last');
                    var $clone = $contents.clone();

                    $clone.find('input').val("");

                    $("#charge").append($clone);
                });
            });
          </script>

+버튼을 눌렀을때 밑에 처럼 동적으로 필드를 생성하고 name과 value의 it_숫자+1[1,2,3,4,5,6,7,8,9]

이 되게 하고싶습니다. 

Copy
<tr>
              <td><input type="text" name="it_12[1]" value="<?php echo $it_12[1] ?>"></td>
              <td><input type="text" name="it_12[2]" value="<?php echo $it_12[2] ?>"></td>
              <td><input type="text" name="it_12[3]" value="<?php echo $it_12[3] ?>"></td>
              <td><input type="text" name="it_12[4]" value="<?php echo $it_12[4] ?>"></td>
              <td><input type="text" name="it_12[5]" value="<?php echo $it_12[5] ?>"></td>
              <td><input type="text" name="it_12[6]" value="<?php echo $it_12[6] ?>"></td>
              <td><input type="text" name="it_12[7]" value="<?php echo $it_12[7] ?>"></td>
              <td><input type="text" name="it_12[8]" value="<?php echo $it_12[8] ?>"></td>
              <td><input type="text" name="it_12[9]" value="<?php echo $it_12[9] ?>"></td>
            </tr>

답변을 작성하려면 로그인이 필요합니다.