Home Discussion Discuss: JavaScript add row to table

  • csiva May 4, 2012 at 8:39 AM

    super

  • Add Dynamic row using Javascriptankiit May 19, 2012 at 9:26 AM

    function removeFormRow(childObj,iValue) { tableId = 'Id_transaction'; if(iValue) { tableId = 'Id_transaction_'+iValue; } var iRowIndex = childObj.parentNode.parentNode.rowIndex; var objTable = document.getElementById(tableId); /** creating table object*/ objTable.deleteRow(iRowIndex); } function addFormRow(Level_Id,Stu_Adm_Type_Id) { var browserName=navigator.appName; var classname; if (browserName=="Netscape") { classname = "class"; } else if(browserName=="Microsoft Internet Explorer") { classname = "className"; } tableId = 'Id_transaction'; if(Level_Id && Stu_Adm_Type_Id) { tableId = 'Id_transaction_'+Level_Id+'_'+Stu_Adm_Type_Id; } var objTable = document.getElementById(tableId); /** creating table object*/ var TotalNoOfRows = objTable.rows.length; /** retrieving no. of rows in a table*/ var LastRowIndex = TotalNoOfRows - 1; /** retrieving index of last row*/ var objCell = objTable.rows[LastRowIndex].getElementsByTagName("td"); /** creating object of columns of last row*/ /** Since we know frist column of last or each row is text box, we can get unique index no. of last row using first element of last row. *****/ var LastObjectId = objCell[0].getElementsByTagName("input")[0].id; /***** or [objCell[0].childNodes[1].id will be work] *****/ var objLastObject = LastObjectId.split("_"); var NewRowIndex = parseInt(objLastObject[objLastObject.length - 1]) + 1; /** Creating new row object and creaing cell object and set respective attributes. */ var objRow = objTable.insertRow(TotalNoOfRows); objRow.id = NewRowIndex; var objCell_1 = objRow.insertCell(0);objCell_1.setAttribute(classname,"myclass"); var objCell_2 = objRow.insertCell(1);objCell_2.setAttribute(classname,"myclass"); var objCell_3 = objRow.insertCell(2);objCell_3.setAttribute(classname,"myclass"); var objCell_4 = objRow.insertCell(3);objCell_4.setAttribute(classname,"myclass"); /** Retrieving contents of first Category combo and Tax Combo */ /** Add contents to the respective cell */ objCell_1.innerHTML="<input type='text' name='data[percent]["+Level_Id+"]["+Stu_Adm_Type_Id+"][]' class = 'textclass' size = '10' id = 'Id_form_"+NewRowIndex+"'>&nbsp;"; objCell_2.innerHTML="<input type='text' name='data[caption]["+Level_Id+"]["+Stu_Adm_Type_Id+"][]' class = 'textclass' size = '10' id = 'Id_form_"+NewRowIndex+"'>&nbsp;"; objCell_3.innerHTML="<input type='text' name='data[max_marks]["+Level_Id+"]["+Stu_Adm_Type_Id+"][]' class = 'textclass' size = '10' id = 'Id_form_"+NewRowIndex+"'>&nbsp;"; objCell_4.innerHTML="<input type='text' name='data[min_marks]["+Level_Id+"]["+Stu_Adm_Type_Id+"][]' class = 'textclass' size = '10' id = 'Id_form_"+NewRowIndex+"'>&nbsp;&nbsp;"+"<img src='"+static_javascript_webroot_path+"img/cross.gif' width='9' height='9' border='0' style='cursor:pointer;' onclick=\"removeFormRow(this,'"+Level_Id+"_"+Stu_Adm_Type_Id+"')\">"; /*if(Level_Id && Stu_Adm_Type_Id) { objCell_5.innerHTML="<img src='"+static_javascript_webroot_path+"img/cross.gif' border='0' style='cursor:pointer;' onclick=\"removeFormRow(this,'"+Level_Id+"_"+Stu_Adm_Type_Id+"')\">"; } else { objCell_5.innerHTML="<img src='"+static_javascript_webroot_path+"img/cross.gif' border='0' style='cursor:pointer;' onclick=\"removeFormRow(this)\">"; }*/ /** End of Process of Adding Row.*/ }

  • hiruwan June 6, 2012 at 1:31 PM

    patta ah

  • DOM dynamic table in javascriptpadmavathi September 5, 2012 at 6:51 PM

    created one table to increment dynamic rows with a addition of two cells values. Sl.No. Item&Desc Qty Rate Amount 1 abc 2 3 6 dynamic row with add option add button and remove button these calculations are not taking place. how to do the multiplication in a DOM dynamic table

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Beginners

add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have... jLabel.setIcon(new ImageIcon("E:/2.jpg"));.But when i pass this jlabel in the row it shows 

Java Beginners

add image in a row of table
add image in a row of table  i have a table in which i have to add image in its row.i am trying to add the image with the help of label i.e i have... jLabel.setIcon(new ImageIcon("E:/2.jpg"));.But when i pass this jlabel in the row it shows 

Programming Tutorials

JavaScript add row dynamically to table
JavaScript add row dynamically to table  ... to add row to a table dynamically then we can also do this with the JavaScript code. In this example we will describe you how to add row dynamically to the table 

JavaScript Tutorial

JavaScript add row to table
JavaScript add row to table      ... will get the table containing the columns Name and Address and a button 'Add row...="javascript:addRow('table')">Add row</button> </html> 

Applet Questions

How to add dropdown list in a row of a sort table applet?
How to add dropdown list in a row of a sort table applet?  How to add dropdown list in a row of a sort table applet 

JSP Servlet Questions

Adding button to each row for the table and adding row to another table
Adding button to each row for the table and adding row to another table  Hi I need to add button to each line in the table(Table data is retrived... row of the table 

Tutorials

Delete and add row from Table View iPhone
Delete and add row from Table View iPhone In this tutorial will learn how to delete and also how to add row into the table view iPhone, with the help of edit... on Navigation bar. Will add this to insert object into the Table View and setting 

JSP Servlet Questions

ADD ROW - JSP-Servlet
ADD ROW  Hi Sir, How to use add row and delete row concept in jsp .  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/add-element.shtml Thanks 

Java Beginners

How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java...()) { Vector row = new Vector(columns); for (int i = 1; i <= columns; i++){ row.addElement( rs.getObject(i) ); } data.addElement( row ); } rs.close(); stmt.close 

Framework Questions

add row in grid using dojo
add row in grid using dojo  add row in grid using dojo 

JSP-Tutorials

Delete a Specific Row from a Database Table
Delete a Specific Row from a Database Table   ... the facility for deleting specific row in a database table. Sometimes, you want... the connection we are going to delete a specific row from the table. If the row 

HTML Questions

add one row after another
add one row after another  how i add one row after another on click of add button $(document).ready(function() { var counter = 2; $("#addData").click(function() { if (counter > 10 

Hibernate Questions

delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row 

Ajax Questions

Hoe to refresh a table row dynamically
Hoe to refresh a table row dynamically  Want to refresh a table data... Friend, Is there a link attribute with every row of a table through which we will able to refresh a particular table row? Please clarify this. Thanks 

MySQL

Mysql Last Row
; Mysql Last Row is used to return the last records from table. Understand... to add the records or rows to the table employee1. mysql>...) Query to view last row of Table named employee1: The Query sorts 

JDBC Questions

Table maximum Row count - JDBC
Table maximum Row count  Dear friends I want to select maximum time entry Status from db. for example : Status : 3 4 6 8 3 5 7 5 5 7 5 3 4 5 2 5 1 my output will be 5 means 5 is maximum time 

Struts Questions

Highlight a corresponding table row - Struts
Highlight a corresponding table row  I have 2 jsps... the table being displayed with rows having links in them(paged display of the table due to huge data) 2.wen klik on the link it leads to Return.jsp 3.now wen 

General

Deleting a Row from SQL Table Using EJB
Deleting a Row from SQL Table Using EJB   ... to delete a row from the SQL Table. Find out the steps given below that describes how to delete a particular row from the database table using EJB. The steps 

SQL Question

What?s the maximum size of a row in SQL table?
What?s the maximum size of a row in SQL table?  What?s the maximum size of a row in SQL table?   Hi, The maximum Row Size is 8060 Bytes in a sql table. Thanks 

SQL Tutorial

Mysql Alter Add Multiple Columns
the table and add multiple columns to the specified table. Understand with Example... the table is created, we use insert into that add the records or rows to the table...: The Query below given is used to modify the table 'employees' and add multiple 

PHP Questions

Add values of drop down menu( select option) to mysql table
Add values of drop down menu( select option) to mysql table   Here is my code <?php echo $row['valveName'].'<td>'.$row['valveId'].'<td>'; echo '<select name="onoff">'; echo '< 

Java-Tutorials

Deleting row and column from a table
Deleting row and column from a table  In this program ,we delete row and column of a table. First we create connection to a database using connection interface and java driver. After it we can delete row using "delete 

Programming Tutorials

JavaScript generate dynamic row
JavaScript generate dynamic row In this section, you will learn how to generate dynamic row using JavaScript. Here a row contain 3 fields(2 textfields,1 text area). Every time if the user click add button, a new row will get added 

SQL Tutorial

Mysql Alter Add Column
;  Mysql Alter Add Column is used to define the existing Table... employees: The insert into add the records or rows into table 'employees...' and add a new column 'city' to the existing table 'employees 

SQL Tutorial

Mysql add primary key
into keyword add the records or rows into table 'employees... rows in set (0.00 sec) Query to add primary key into the Table...'. mysql> alter table employees -> add primary key (empid 

Java Beginners

row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query 

Java Beginners

row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query 

JSP Servlet Questions

Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator... into the table. For this all the rows displayed and two rows with empty text boxes, he 

JSP Servlet Questions

Insert specific fields into table dynamically for each row.
Insert specific fields into table dynamically for each row.  There is a table containing 20 fields and 2 of those are empty. The administrator... into the table. For this all the rows displayed and two rows with empty text boxes, he 

SQL Question

mysql alter table add column
mysql alter table add column  Hi, What is the syntax of mysql alter table add column? Thanks   Hi, Here is mysql alter table add column example: ALTER TABLE employee ADD address VARCHAR(50); Read more at MySQL Add 

DMCA.com