Lập trình , Thiết kế website, Auto Game Online

Script add thêm một thẻ 

0
0
(0)

  Script add thêm một thẻ 

   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



<title>-:- THUVIENIT -:- </title>

<script language="javascript">



    function addFile(objName) {

        var tbl_process = document.getElementById(objName);        

        var tr = tbl_process.insertRow(tbl_process.rows.length);

        var td1 = document.createElement("td");

        var td2 = document.createElement("td");

        var td3 = document.createElement("td");

        

        td1.innerHTML = "<input title='Tiêu đề' style='width:100%;' type='text' name='TieuDe_" + objName + "_" + tr.rowIndex + "'></input>" ;    

        td2.innerHTML = "<input title='Tập tin' style='width:100%;' type='file'  name='DuongDan_" + objName + "_" + tr.rowIndex + "' onKeyPress='return false;'></input>";        

        td3.innerHTML = "<input  type='button' value='Xoá' onclick='deleteRow(this)'>";        

        td3.align="center";

        tr.appendChild(td1);

        tr.appendChild(td2);

        tr.appendChild(td3);

        tr.className = "TVIT" ;

        td1.childNodes[0].focus();

    }

    

    function deleteRow(obj) {

        obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode.rowIndex) ;

    }

</script>

</head>

<body>

<table id="DK" width="99%" align="center" bgcolor="#99cccc" border="0" cellpadding="3" cellspacing="1">

    <tbody>

        <tr>

            <td width="25%">Tiêu đề</td>

            <td width="65%">Tên tập tin</td>

            <td align="center"><input  value="Thêm" onClick="addFile('DK')" type="button"></td>

        </tr>

        <tr>

            <td><input title="Tiêu đề" style="width: 100%;" name="TieuDe_DK_1" type="text"></td>

            <td><input title="Tập tin" style="width: 100%;" name="DuongDan_DK_1" onKeyPress="return false;" type="file"></td>

            <td align="center"><input  value="Xoá" onClick="deleteRow(this)" type="button"></td>

        </tr>

        <tr>

            <td><input title="Tiêu đề" style="width: 100%;" name="TieuDe_DK_2" type="text"></td>

            <td><input title="Tập tin" style="width: 100%;" name="DuongDan_DK_2" onKeyPress="return false;" type="file"></td>

            <td align="center"><input  value="Xoá" onClick="deleteRow(this)" type="button"></td>

        </tr>

    </tbody>

</table>

</body>

</html>



Demo http://thuvienit.org/forum/demo/addtr/index.html

 

Theo thuvienit

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave A Reply

Your email address will not be published.