Use JS how to insert the row dynamically!

Source: Internet
Author: User
Tags commit insert return
js| Insert | Dynamic <script language= "JavaScript" >
Constructors
function Instercell (tableid,content,place) {
Identification of the This.mtableid=tableid;//table
The content of This.minscontent=content;//inster
This.minsplace=place;//inster's Location

This.cinscell=inscell;
This.cclearcell=clearcell;

}
Insert
function Inscell () {
Str=eval (this.mtableid+ ". cells[" +this.minsplace+ "]);//This is not to write!
Str.innerhtml= ' <table cellspacing=\ ' 0\ ' cellpadding=\ ' 0\ ' border=\ ' 0\ ' ><tr> ';
This.mtableid.cells[this.minsplace].innerhtml=this.minscontent;

This.mtableid.cells[this.minsplace].innerhtml= ' </tr></table> ';
this.minsplace++;
}
Clear
function Clearcell () {
for (i=0;i<this.mtableid.cells.length/2-1;i++) {
This.mtableid.cells[2*i+1].innerhtml= "";
}
}
Str= ' <TD> Bank original balance </TD> ';
str+= ' <td><input type= ' text ' name= ' earning ' ></TD> ';
str+= ' <td><input type= ' text ' name= ' payout ' ></TD> ';
str+= ' <td><input type= ' text ' name= ' Cashonhand ' > </TD> ';
str+= ' <td><input type= ' text ' name= ' Cashonhandremark ' ></TD> ';

var ins=new instercell ("T1", "str", 1);
Ins.cinscell ();

</script>

Code:--------------------------------------------------------------------------------
<title> Shipping List </title>
<body bgcolor= "#F2FDE8" text= "000000" link= "000000" vlink= "000000" alink= "000000" >

<script language= "JavaScript" >

function Tbladdrow ()
{
var i=lines.rows.length;
var row = Table1.insertrow (Table1.rows.length);
var col = Row.insertcell (0);
col.innerhtml = "<input id=line[" +i+ "][COMMCD" name=line["+i+";
Col = Row.insertcell (1);
col.innerhtml = "<input id=line[" +i+ "][serialno" name=line["+i+";
Col = Row.insertcell (2);
col.innerhtml = "<input id=line[" +i+ "][qty" name=line["+i+";
}
function Tbladdrows (items)
{
for (i = 1; I <= items; i++)
{
Tbladdrow ();
}
}
function Delrow ()
{
if (lines.rows.length==0)
{
return false;
}
Lines.deleterow ();
}

</SCRIPT>

<CENTER>
&LT;P&GT;&LT;H1 class=title> Shipping List </H1></P>
<form action= "testlines.php" Method=post id=form1 name=form1>
<!--language=javascript onsubmit= "return Checknumarray (' Qty ')"-->
<P> Ordering Unit: Demo retailer
Date: 2002-02-25
Order Number:
<input Id=items Name=items value=1>
<input id=corpcd name=corpcd Type=hidden value=26>
<input Id=eventid Name=eventid Type=hidden value=2266>
<input id=addrow name=addrow Type=button value= plus one line onclick= "Tbladdrows (items.value);" >
<input id=deloneline name=deloneline Type=button value= Delete line language=javascript onclick= "return Delrow ()" >
</P>
<table id=table1 border= "1" cellpadding= "4" cellspacing= "0" bordercolorlight= "#006830" bordercolordark= "#FFFFFF" Width= "60%" >
<tr bgcolor= "#E1F0C4" >
<TH> Item No. </TH>
<TH> Production lot Number </TH>
<TH> Quantity </TH>
</TR>
<tbody id= "lines" Name= "lines" >
<!--
<tr>
<td><input ID=COMMCD NAME=COMMCD value=jc002></td>
<td><input Id=serialno Name=serialno value=9911></td>
<td><input Id=qty Name=qty value=0.0></td>
</tr>
-->
</tbody>
<!--
</TABLE>
&LT;H2 class=title> Inventory List </H2>
<table border= "1" cellpadding= "4" cellspacing= "0" bordercolorlight= "#006830" bordercolordark= "#FFFFFF" width= "60% ">
<tr bgcolor= "#E1F0C4" >
<TH> Item No. </TH>
<TH> Production lot Number </TH>
<TH> Inventory Quantity </TH>
</TR>

</TABLE>-->
<P>

<input id=commit name=commit type=submit value= Submit >

</P>
</FORM>
</CENTER>
</body>


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: [email protected] 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.