JSP dynamic addition of columns for IE and Firefox

Source: Internet
Author: User

 

 VaR cellcount = 0; <br/> function addtr () {<br/> cellcount ++; <br/> // obtain the table to be operated <br/> var table = document. getelementbyid ("T1"); </P> <p> // dynamically Add rows <br/> var newrow = document. createelement ("TR"); <br/> // dynamically create a column <br/> var newcell0 = document. createelement ("TD"); <br/> var newcell1 = document. createelement ("TD"); <br/> // Add content dynamically <br/> newcell0.appendchild (document. createtextnode ("field" + (cellcount + 1) + ""); <br/> newrow. appendchild (newcell0); <br/> newcell1.innerhtml = "<input type = 'text' name = 'cell" + cellcount + "'>"; <br/> newrow. appendchild (newcell1); <br/> document. getelementbyid ("tbody1 "). appendchild (newrow); </P> <p>/********************** the method can be used in IE, but not in Firefox <br/> // dynamically Add rows <br/> var newrow = table. insertrow (); <br/> // Add a column to the new row <br/> var newcell0 = newrow. insertcell (); <br/> newcell0.innerhtml = "field" + (cellcount + 1); <br/> var Newcell = newrow. insertcell (); <br/> // add content to the column <br/> Newcell. appendchild = (document. createtextnode ("<input type = 'text' name = 'cell" + cellcount + "'>"); <br/> // Newcell. innerhtml = "<input type = 'text' name = 'cell" + cellcount + "'> "; <br/> ********************/<br/> document. getelementbyid ("cellcount "). value = (cellcount + 1 ); <br/>}</P> <p> <Table width = "200" border = "0" id = "T1"> <br/> <tbody id = "tbody1 "> <br/> <tr> <br/> <TD nowrap =" nowrap "> <br/> database <br/> </TD> <br/> <TD style = "text-align: left; "mce_style =" text-align: Left; "> <br/> <JSP: Include page = ".. /Includes/dblist. JSP "/> <br/> </TD> <br/> </tr> <br/> <TD> <br/> table name <br/> </TD> <br/> <input name = "tbname" type = "text"/> <br/> </TD> <br/> </tr> <br/> <TD> <br/> Primary Key <br/> </TD> <br/> <TD> <br/> <input name = "rowkey" type = "text"/> <br/> </TD> <br/> </tr> <br/> <tr> <br/> <TD nowrap = "nowrap"> <br/> Field 1 <br/> </TD> <br/> <TD> <br/> <input name = "cell0" type = "text"/> <br/> </TD> <br/> </tr> <br/> </tbody> <br/> </table> <br/> <Table> <br/> <tr> <br/> <TD nowrap = "nowrap"> <br/> <input name = "" type = "button" value = "add field" align = "Left" onclick = "addtr (); "/> <br/> </TD> <br/> <s: submit name = "addteictb" value = "Submit" align = "Left" method = "addteictb"/> <br/> </TD> <br/> <TD> <br /> <input type = "reset" value = "reset"/> <br/> </TD> <br/> </tr> <br/> </table>

 

 

Related Article

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.