日期:2014-05-16  浏览次数:20446 次

javascript table 动态创建 tr ,删除tr 等相关操作
使用框架或者才采用 clonse 方式也可以实现。
直接javascript操作:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<head>
<title>UPLOAD HTML</title>
<link href="dojo-release-1.5.0/dijit/themes/dijit.css" rel="stylesheet" />
<link href="dojo-release-1.5.0/dijit/themes/tundra/form/Button.css"
rel="stylesheet" />
<link href="dojo-release-1.5.0/dijit/themes/tundra/ProgressBar.css"
rel="stylesheet" />
<script>
        djConfig = {
            isDebug: false,
popup:true,
            parseOnLoad: true
        }
    </script>
<script src="dojo-release-1.5.0/dojo/dojo.js"></script>
<script>
        dojo.require("dojox.form.FileUploader");
        dojo.require("dijit.form.Button");
       
        dojo.addOnLoad(function(){

var props = {
uploadUrl:"test/uploadFile.action",
fileMask:[
["All Images", "*.jpg;*.jpeg;*.gif;*.png"]
],
deferredUploading:false,
degradable:true,
                uploadOnChange:false,
                selectMultipleFiles:true,
                devMode:true,
                isDebug:false,
                showProgress:false
};

if(dojo.byId("btnF")){
var f = new dojox.form.FileUploader(props, "btnF");
dojo.connect(dijit.byId("fSubmit"), "onClick", function(){
alert('click');
var param = {author:dojo.byId('author').value};
f.upload(param);
});
dojo.connect(f, "onChange", function(dataArray){
alert("onChange");
                     dojo.forEach(dataArray, function(d){
                         alert(d);
                    addTr(d);
                     });

});
dojo.connect(f, "onComplete", function(dataArray){
alert("onComplete:" + dataArray);
dojo.forEach(dataArray, function(d){
alert(d);
});
});
}



});

function addTr(objFile){
alert("add");
var table = document.getElementById("tableBody");  
var tr = document.createElement('tr');  
table.appendChild(tr);  
var td1 = document.createElement('td');  
tr.appendChild(td1);  
td1.innerHTML = objFile.name;
var td2 = document.createElement('td');  
tr.appendChild(td2); 
if(ob