728x90
    
    
  목동코딩: 코딩수업
아래의 화면에서 복수의 input의 value를 가져와서 DB에 저장하는 방법과 새로운 table row를 만들어서 새로운 record를 추가하는 방법입니다.

<script>
    function addItems() {
        $("input[name=ItemCode]").each(function(idx) {
            // 해당 input Value 가져오기
            var id = $(this).attr('id');
            var ItemCode = $("input[name=ItemCode]:eq(" + idx + ")").val();
            console.log(id + ":" + ItemCode);
        });
        var ret = confirm("항목을 추가하시겠습니까?");
         if(!ret){
            return false;
        }
        var row = "";
        row = row + "<tr>";
        row = row + "<td><input  type='button' value='' style='width: 100%;'></td>";
        row = row + "<td><input  type='text' value='' style='width: 100%;'></td>";
        row = row + "<td><input  type='text' value='' style='width: 100%;'></td>";
        row = row + "<td><input  type='text' value='' style='width: 100%;'></td>";
        row = row + "<td><input  type='text' value='' style='width: 100%;'></td>";
        row = row + "</tr>";
        $('#itemsTable').append(row);
}
</script>
<table id="itemsTable" class="table table-striped">
  <th width="5%">
    삭제
  </th>
  <th  width="5%">
    기호
  </th>
  <th  width="20%">
    품명
  </th>
  <th  width="10%">
    가격
  </th>
  <th  width="60%">
    설명
  </th>
</tr>
</table>

728x90
    
    
  '코딩교육 > Web' 카테고리의 다른 글
| 목동코딩, Asp.net mvc EF에서 Data 추가하는 방법 (0) | 2021.09.23 | 
|---|---|
| 목동코딩,Ajax Click으로 Delete Table Row (0) | 2021.09.20 | 
| 목동코딩학원, Html, Modal 폼 열고 닫는 방법 (0) | 2021.09.15 | 
| 목동코딩학원, Html, Javascript 크릭시 이미지 크게하는 방법 (0) | 2021.09.15 | 
| 목동코딩, html, Input 입력 유효성 체크하는 방법 (1) | 2021.09.15 |