JS Dynamic Create TABLE,TR,TD and assign value of concrete implementation _javascript skills

Source: Internet
Author: User
Results Library Modifications:
Require a list of topics to change with the result type change
Online query data start, in the Result type dropdown box add change () event trigger DWR, Query topic Collection--Create/Edit table dynamically
The outline code is as follows:
Js
Copy Code code as follows:

Dynamically get Topic data
function Getzts () {
ParentID = document.getElementById ("Bselect1"). Value;
if (parentid!= "") {
Dwrmethod.getztlist (PARENTID,CALLBACK5);
}else{
Clear the data for the topic table
var T=document.getelementbyid ("Zhutitable"); Get table
var length= t.rows.length; Get the number of rows under table
if (length!=0) {//If there is a row, empty
for (Var i=length-1;i>=0;i--)
{
T.deleterow (i);
}
}
var r = T.insertrow ();
var c = R.insertcell ();
C.innerhtml= "no topic list";
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 is a row, empty
for (Var i=length-1;i>=0;i--)
{
T.deleterow (i);
}
}
if (provinces.length>0) {
for (var i = 0; i < provinces.length; i++) {
Tr
if (i%4==0) {
var r = T.insertrow (t.rows.length);//Create a new row
}
Td
var c = R.insertcell (); Create a new column
c.innerhtml = "<input type=" checkbox ' name= ' zhutiids ' value= ' +provinces[i][0]+ ' > ' +provinces[i][1];
}
}else{
var r = T.insertrow ();
var c = R.insertcell ();
C.innerhtml= "no topic list";
}
document.getElementById (' zhutitable '). appendchild (t);
}

Html
Copy Code code as follows:

<tr>
&LT;TD class= "Add_tit" > Achievement type </td>
<td>
<s:select id= "Bselect1" name= "PruType1" onchange= "Getzts" (); " List= "Ptypelist" listkey= "id" listvalue= "productiontypename" headerkey= "" headervalue= "--Please select--"/>
<label class= "Note4" >*</label>
</td>
</tr>
[HTML]
<tr>
&LT;TD class= "Add_tit" > Theme </td>
&LT;TD id= "table1" style= "padding-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;" >
<table id= "zhutitable" border= "0" cellpadding= "0" cellspacing= "0" width=100% class= "table_table" >
<tr>
&LT;TD style= "color:red;" > Note: Please select the result type first </td>
</tr>
</table>
</td>
</tr>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.