M
michael
Good Morning Everyone,
I am writing a script to add and remove rows from a table. Here are the
two functions:
function newRow(rowNo)
{
var theTable = document.getElementById("table1");
var newRow = theTable.insertRow(rowNo);
}
function removeRow(rowNo)
{
var theTable = document.getElementById("table1");
if (rowNo >= 0 && rowNo <= theTable.rows.length);
{
theTable.deleteRow(rowNo);
}
}
The functions are called from images in the table as follows:
<tr><td><input type="image" src="removeRow.png" alt="Remove Row"
title="Remove Row" onclick="removeRow(10);">
<input type="button" src="newRow.png" alt="New Row" title="Insert New
Row" onclick="newRow(20);"></td><td>...
When the "Remove Row" icon is clicked, the row is removed nicely, however,
when the "New Row" icon is clicked, a new row appears and then the page
immediately reloads, without the new row. After the page has reloaded,
the address in the addressbar has "?x=6&y=7" appended to the original
address.
If I change the input type of the "New Row" to "Button", the new row
appears nicely and the page does not reload.
I have tested this on Internet Explorer, Firefox, Opera and Konqueror all
with the same result.
Does anyone have an idea why this happens and what I can do to keep using
the input type="image" without having the page reload?
Cheers!
Michael
I am writing a script to add and remove rows from a table. Here are the
two functions:
function newRow(rowNo)
{
var theTable = document.getElementById("table1");
var newRow = theTable.insertRow(rowNo);
}
function removeRow(rowNo)
{
var theTable = document.getElementById("table1");
if (rowNo >= 0 && rowNo <= theTable.rows.length);
{
theTable.deleteRow(rowNo);
}
}
The functions are called from images in the table as follows:
<tr><td><input type="image" src="removeRow.png" alt="Remove Row"
title="Remove Row" onclick="removeRow(10);">
<input type="button" src="newRow.png" alt="New Row" title="Insert New
Row" onclick="newRow(20);"></td><td>...
When the "Remove Row" icon is clicked, the row is removed nicely, however,
when the "New Row" icon is clicked, a new row appears and then the page
immediately reloads, without the new row. After the page has reloaded,
the address in the addressbar has "?x=6&y=7" appended to the original
address.
If I change the input type of the "New Row" to "Button", the new row
appears nicely and the page does not reload.
I have tested this on Internet Explorer, Firefox, Opera and Konqueror all
with the same result.
Does anyone have an idea why this happens and what I can do to keep using
the input type="image" without having the page reload?
Cheers!
Michael