Sagewire Logo

adding rows to a table

5 Message(s) by 3 Author(s) originally posted in javascript programming


From: benkasminbullock Date:   Friday, October 26, 2007
I have a script which adds row s to an HTML table . However, the script
functions only for Firefox and not for Internet Explorer. Here is a
test case which works on Firefox 2.0.0.8 but doesn't work on Internet
Explorer 6.0.

Can anyone explain why this doesn't work, and is there a way to make
it work with Internet Explorer?

What bothers me is that modifying the script slightly to change the
table to a <ul> and the <tr> to a <li> does work with Internet
Explorer.

Thanks for any help.

%%%%%%%%%%%%%%% start of example

<html>
<head>
<script>
function add_a_row()
{
alert ("Add a row");
var cell = document.createElement("td");
cell.appendChild(document.createTextNode("Second"));
var row = document.createElement("tr");
row.appendChild(cell);
var mytable = document.getElementById("mytable");
mytable.appendChild(row);
}
</script>
<style>
table { border-style: outset; border-width: 3; }
td { border-style: inset; border-width: 3; font-size: 50; }
</style>
</head>
<body>
<table id="mytable">
<tr><td>First</td></tr>
</table>
<form>
<input type="button"
onclick="add_a_row()"
value="add a row">

</form>
</body>
</html>

%%%%%%%%%%%%%%%%% end of example


From: RobG Date:   Friday, October 26, 2007
On Oct 26, 4:11 pm, "benkasminbull...@xxxxxxxxxxx"
wrote in message:
I have a script which adds rows to an HTML table. However, the script
functions only for Firefox and not for Internet Explorer. Here is a
test case which works on Firefox 2.0.0.8 but doesn't work on Internet
Explorer 6.0.



<FAQENTRY>

Here it is again... :-)

</FAQENTRY>

Can anyone explain why this doesn't work, and is there a way to make
it work with Internet Explorer?



When adding rows to a table:

1. Do not ever user innerHTML (OK, you did not do that)

2. Do not append rows to the table, append them to a
tableSection element (tbody, thead or tfoot)

3. Consider using insertRow(-1) on the table or tableSection
so the row is created and appended in one statement.<URL: http://developer.mozilla.org/en/docs/Gecko_DOM_Reference:Examples#Example_8:_Using_the_DOM_Table_Interface
--
Rob





From: benkasminbullock Date:   Friday, October 26, 2007
wrote in message:

> Can anyone explain why this doesn't work, and is there a way to make
> it work with Internet Explorer?
When adding rows to a table:
1. Do not ever user innerHTML (OK, you did not do that)
2. Do not append rows to the table, append them to a
tableSection element (tbody, thead or tfoot)
3. Consider using insertRow(-1) on the table or tableSection
so the row is created and appended in one statement.
<URL:http://developer.mozilla.org/en/docs/Gecko_DOM_Reference:Examples#Exa...



Thank you very much for your help.

Incidentally it says on the web pages that only IE needs to have the
elements added to tbody, but in fact Firefox was adding some extra
space at the top of the table every time I recreated it which was the
bug which drove me to test it with Internet Explorer in the first
place. Putting the elements onto <tbody> stopped the Firefox problem.

Thanks again.


From: SAM Date:   Saturday, October 27, 2007
RobG a écrit :
<URL: http://developer.mozilla.org/en/docs/Gecko_DOM_Reference:Examples#Example_8:_Using_the_DOM_Table_Interface



My english is too poor and I did not understand if this example is
correctly interpreted by IE Windows , is it or not ?
(I have not Windows to test it)

--
sm


From: SAM Date:   Saturday, October 27, 2007
benkasminbullock@xxxxxxxxxxx a écrit :
wrote in message:

<URL:http://developer.mozilla.org/en/docs/Gecko_DOM_Reference:Examples#Exa...
Incidentally it says on the web pages that only IE needs to have the
elements added to tbody, but in fact Firefox was adding some extra
space at the top of the table every time I recreated it



With the above example my Firefox add no space ...
(or it is very very very small ?)

--
sm



Next Message: setTimeout - clearTimeout - Why Does not This Work?


Blogs related to adding rows to a table

TOTD #10: Consuming JSON and XML representations generated by a ...
The getXML() method returns only the table rows data in an XML format. This XML representation of the resource is then processed by a stylesheet (specified later in the jMaki application) and converted into the JSON format as expected ...

Adding backing bean action to every row in data table in jsf
Hi all here i am giving example for how to add action for every row in datatables in jsf for more struts or jsf or java examples check our site at http://strutsland.info. If you need any help please send a message to us. select.jsp ...

652 Part III . Document Objects Reference The (Web hosting billing)
Finally, to rid yourself of all cells in a row, use the deleteRow()method of the TABLE and table row section element objects. Example See Listing 27-2 for an example of inserting cells during the row insertion process. ...

adding printers in active directory
... xp adding row adding row to datagrid adding row to dataset adding rows dynamically adding rows dynamically to html table adding rows in datagrid adding rows in excel adding rows to a datagrid adding rows to a dataset adding rows to ...

How do I website delete all but the top 10 posts in a table I have ...
ADD INDEX (name) to companies. Kronuz, show the new EXPLAIN output, please? it took 2min for adding the ip_end index. scholar, o_O. would it take much longer for the combined key? The table has over a million rows . ...

Re: not coming up
UIData & its getRowData() method > to map the table row between UI & managedbean > > I don't know to which JIRA I should report this. Kindly help > -----Original Message----- > From: Mike Kienenberger [mailto:mkienenb@gmail.com] > Sent: ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional