'자바스크립트 행추가 필드추가'에 해당되는 글 1건

  1. 2009.04.10 자바스크립트 행추가 필드추가
javascript 행추가삭제
.

<html>
<script>
    var rowIndex = 1;
    function addFile(form,k){
        if(rowIndex > (5-k)) return false;
        var oCurrentRow,oCurrentCell;
        var sAddingHtml;
        oCurrentRow = insertTable.insertRow();
        rowIndex = oCurrentRow.rowIndex;
        oCurrentCell = oCurrentRow.insertCell();
        rowIndex++;
        oCurrentCell.innerHTML = "<tr><td colspan=4><INPUT class=input TYPE=FILE NAME='filename" +rowIndex + "' size=25></td></tr>";
        form.rowCount.value = rowIndex;
    }
   
    //첨부파일 삭제
    function deleteFile(form){
        if(rowIndex<2){
            return false;
        }else{
            form.rowCount.value = form.rowCount.value - 1;
            rowIndex--;
            insertTable.deleteRow(rowIndex);
        }
    }
   

</script>

<body>

<form name="write">
     <table name='insertTable' id='insertTable' border=0 cellpadding=0 cellspacing=0>
        <tr><td valign=bottom><INPUT type='file' maxLength='100' name='filename1' size='25'></td>
        <td width=100>
        <input type="button" value="추가" onClick="addFile(write,1)" border=0 style='cursor:hand' hspace=4>
        <input type="button" value="삭제" onClick='deleteFile(write)' border=0 style='cursor:hand'>
        </td>
        </tr>
    </table>
    <input type="hidden" name="rowCount" value="1">
    <input type="submit">
    </form>                      
</body>
</html>

Posted by [czar]
,