Home > Web Front-end > JS Tutorial > Specific implementation of JS dynamically creating Table, Tr, Td and assigning values ​​_javascript skills

Specific implementation of JS dynamically creating Table, Tr, Td and assigning values ​​_javascript skills

WBOY
Release: 2016-05-16 17:29:44
Original
1162 people have browsed it

Modification of the achievement database:
Require the topic list to change with the change of achievement type
Start work after querying the information online, add the change() event in the drop-down box of the achievement type to trigger Dwr, query the topic collection - dynamically create/edit Table
The summary code is as follows:
JS

Copy code The code is as follows:

//Dynamic Get topic data
function getzts(){
parentId = document.getElementById("bselect1").value;
if(parentId!=""){
dwrMethod.getZtList(parentId,callback5) ;
}else{
                                                                             // Get the number of rows under the Table
if(length!=0){ //If there are rows, clear them
for(var i=length-1;i>=0;i--)
{
t.deleteRow(i);
}
}
var r = t.insertRow(); 🎜> c.innerHTML=" No topic list yet";
document.getElementById('zhutiTable').appendChild(t);
}
}
function callback5(provinces){
var t=document.getElementById( "zhutiTable"); //Get Table
var length= t.rows.length; //Get the number of rows under Table
if(length!=0){ //If there are rows, clear them
for(var i=length-1;i>=0;i--)
{
t.deleteRow(i);
} }
}
if(provinces.length> 0){                                                                                                                                      var r = t. insertRow(t.rows.length);//Create new rows
                                         The column of
c.innerHTML = "" provinces[i][1]; r = t.insertRow();
var c = r.insertCell();
c.innerHTML="No topic list";
}
document.getElementById('zhutiTable'). appendChild(t);
}


html
Copy code The code is as follows:


< ;td class="add_tit">Result type


                                                                                         


[html]

Theme

  
                                              " :Please select the result type first
                                      
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template