472,952 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

deleteRow causes Netscape 7 to crash - why ?

Dom
Hi,

I am trying to get a dynamic table going. You click a button to add a
row. In the newly created row a button to delete the row is placed
(try the code example below). In Netscape, pressing the delete row
button crashes the browser. Why ? What is the correct way to do this ?

I am stumped why this following code works in IE and Opera but crashes
Netscape 7 (ie makes it disappear and try to send a bug report etc).

Any help would be much appreciated.

Copy and save the following code example and try running in Netscape 7
(or Mozilla 1.4) . It works fine in IE 6 and Opera 7. I've tried all
sorts of tweaking around but to no avail.

I need some expert help. Perhaps suggest the correct or other better
way of implementing this.
Here's the code:

<html><head>

<script language="javascript">

function createTableRow(oTable)
{
var thetable = document.all ? document.all[oTable] :
document.getElementById(oTable); // get table object handle
var nrows=thetable.rows.length; // get current tablesize
var row = thetable.insertRow(nrows); // create a new row object
var cell ;

cell = row.insertCell(0); cell.innerHTML="row"+nrows; // create a new
cell in the new row

// this will crash my netscape 7.2 browser but works fine in Opera
and IE
cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(this.parentNode.parentNode .rowIndex)'>Delete</button>";

// This will behave strangely in that it will remove ALL rows from
the table - why ??? again, it works in Opera and IE.
//cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(0)'>Delete</button>";
}

function deleteTableRow(nth)
{
var thetable = document.all ? document.all['tbl'] :
document.getElementById('tbl'); // get the tbl table object handle
thetable.deleteRow(nth); // delete the nth row from the table ####
this crashes Netscape 7 and 6 - WHY ????
}
</script>
<body bgcolor=white>
<form name="form1" method="post" action=""
enctype="multipart/form-data" >
<table border=1 width="232">
<!--col width=150><col width=150><col width=80-->
<tr><th>Name</th><th>Qty</th></tr>
</table>

<table id='tbl' border=1>
<col width=150><col width=150><col width=80>
<!-- TABLE for the order items -->
</table>

<input TYPE="button" VALUE="Add Item"
onclick="createTableRow('tbl')">
<input type="submit" name="Submit" value="Submit" >

</form></body></html>
Jul 20 '05 #1
2 3018
DU
Dom wrote:
Hi,

I am trying to get a dynamic table going. You click a button to add a
row. In the newly created row a button to delete the row is placed
(try the code example below). In Netscape, pressing the delete row
button crashes the browser. Why ? What is the correct way to do this ?

I am stumped why this following code works in IE and Opera but crashes
Netscape 7 (ie makes it disappear and try to send a bug report etc).

Any help would be much appreciated.

Copy and save the following code example and try running in Netscape 7
(or Mozilla 1.4) . It works fine in IE 6 and Opera 7. I've tried all
sorts of tweaking around but to no avail.

I need some expert help. Perhaps suggest the correct or other better
way of implementing this.
Here's the code:

<html><head>

<script language="javascript">

function createTableRow(oTable)
{
var thetable = document.all ? document.all[oTable] :
document.getElementById(oTable); // get table object handle
Since the rest of the function can not be executed by MSIE 4, then there
is no point to branch the code in the above instruction.
var nrows=thetable.rows.length; // get current tablesize
var row = thetable.insertRow(nrows); // create a new row object
var cell ;

cell = row.insertCell(0); cell.innerHTML="row"+nrows; // create a new
cell in the new row

// this will crash my netscape 7.2 browser
we're still at NS 7.1 :)
but works fine in Opera and IE
cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(this.parentNode.parentNode .rowIndex)'>Delete</button>";
I tried a few modifications of the above instruction and nevertheless,
NS 7.1 always crashed. You might have found an old - but rare - crash
bug here ... since the code works and does not crash in Opera 7.2 and
Mozilla 1.5RC2

// This will behave strangely in that it will remove ALL rows from
the table - why ??? again, it works in Opera and IE.
//cell = row.insertCell(1); cell.innerHTML="<button
onclick='deleteTableRow(0)'>Delete</button>";
}

function deleteTableRow(nth)
{
var thetable = document.all ? document.all['tbl'] :
document.getElementById('tbl'); // get the tbl table object handle
thetable.deleteRow(nth); // delete the nth row from the table ####
this crashes Netscape 7 and 6 - WHY ????
}
This deleteTableRow function could be safely removed and replaced entirely.
</script>
<body bgcolor=white>
<form name="form1" method="post" action=""
enctype="multipart/form-data" >
<table border=1 width="232">
<!--col width=150><col width=150><col width=80-->
<tr><th>Name</th><th>Qty</th></tr>
</table>

<table id='tbl' border=1>
<col width=150><col width=150><col width=80>
<!-- TABLE for the order items -->
</table>

<input TYPE="button" VALUE="Add Item"
onclick="createTableRow('tbl')">
<input type="submit" name="Submit" value="Submit" >

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

Your code could be optimized and be made much more compact at several
places. Your code works in Mozilla 1.5RC2 but it crashes in NS 7.1.
I would avoid resorting to innerHTML everywhere all the time and only
use DOM 2 methods. Here, with DHTML modifying the page, such coding
policy is even more true and recommendable.

In your code, your table "tb1" has 3 columns but each new row only has 2
cells (without any column span).
Despite several efforts, I could not come up with a solution which would
work in NS 7.1.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #2
"DU" <dr*******@hot-R-E-M-O-V-E-mail.com> wrote in message
news:bm**********@news.eusc.inter.net...
<snip>
I tried a few modifications of the above instruction and
nevertheless, NS 7.1 always crashed. You might have found
an old - but rare - crash bug here ... since the code works
and does not crash in Opera 7.2 and Mozilla 1.5RC2

<snip>

I could not get Netscape 7.02 to crash but I did get Mozilla 1.3 to
crash so I tested in that until it worked (at my first alteration).

The button element that is being written into the HTML has no type
attribute so the HTML 4 specification requires it to default to
type="submit". Obviously submitting a form while simultaneously deleting
it's submit button is a bit much for Mozilla 1.3 so it crashes. Adding a
type="button" attribute solved the problem.

(Another example of how understanding what represents valid HTML and its
meaning would have avoided JavaScript errors ;-)

Richard.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Geddes | last post by:
In both IE6 and Netscape 7: insertRow method of tbody is behaving as expected: - inserts a new row - increases tbody.rows.length BUT deleteRow is not doing the opposite. It DOES delete the...
7
by: Jonas Smithson | last post by:
Hello all, I have an absolute positioned parent div, and nested inside it is an absolute positioned child div -- I mean the div *code* is nested inside, but the child is physically positioned so...
10
by: Alex Vinokur | last post by:
GNU g++ 3.3.3, Cygwin // Stuff static char* mbuffer = NULL; // Stuff void doit()
1
by: John C | last post by:
Importing DBase files I get to the screen titled "Select Source Table and Views" And none appear in the list. (I can get the list displayed about once in ten tries) From that screen anything causes...
13
by: M B HONG 20 | last post by:
Hi all - I have a .NET web service running on a remote machine, and I have Netscape Navigator 7.0 accessing it through javascript on the client side through SOAP javascript coding. Everything...
18
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes...
8
by: Adam Louis | last post by:
I would like help resolving this problem. I'm a novice who's been hired to query a hospital database and extract useful information, available to me only in a dynamically generated, downloadable...
2
by: Composer | last post by:
One form in my Access 2000 mdb causes a crash whenever I close it. The crash is of the type where I get a "Please tell Microsoft about this problem". Easy, you think! Well, here are the things...
4
by: jamescostello | last post by:
The code below is part of a script that is imported by a webpage. I am trying to modify a table on that webpage using this code. I can't modify the actual webpage itself. I would like to simply...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.