S
Stefan Mueller
The following code (HTML) generates a table. Now I'd like to insert a new
row by a javascript.
The following code (javascript) works with the Internet Explorer and also
with Mozilla. However, the inserted button (onClick) in the table does not
work with the Internet Explorer. It only works with Mozilla.
I'm trying the whole Sunday without any success.
Please give me a hint.
Stefan
PS: It seems that also the width-statement (width:75) is not working with
the Internet Explorer.
=============================================================
<html>
<script type="text/javascript">
function InsertRow(WhereToInsert) {
var xtable
var xrow
var xcell
var xelement
xtable = document.getElementById("MyTable")
xrow = xtable.insertRow(WhereToInsert)
xcell = xrow.insertCell(0)
xcell.innerHTML = "Inserted Row"
xcell.setAttribute("bgColor", "#008888")
xcell = xrow.insertCell(1)
xcell.innerHTML = ""
xcell.setAttribute("bgColor", "#008888")
xelement = document.createElement("input")
xelement.setAttribute("type", "button")
xelement.setAttribute("style", "width:75")
xelement.setAttribute("value", "Click")
xelement.setAttribute("onClick", "alert('Wow, it works!')")
xcell.appendChild(xelement)
}
</script>
<body>
<form name="MyForm">
<table id = "MyTable" width = "400" align = "center">
<tr>
<td width = "50%" style = "background-color:#00ffff">
Text Row 1
</td>
<td width = "50%" style = "background-color:#00ffff">
<input type = "button" style = "width:75" value = "Click"
onClick = "alert('Wow, it works!')">
</td>
</tr>
<tr>
<td width = "50%" style = "background-color:#00ffff">
Text Row 2
</td>
<td width = "50%" style = "background-color:#00ffff">
<input type = "button" style = "width:75" value = "Click"
onClick = "alert('Wow, it works!')">
</td>
</tr>
</table>
<p>
Where to insert the new row:
<input type = "text" name = "InsertRowNumber" value = "">
<input type = "button" value = "Add Row" onClick =
"InsertRow(document.MyForm.InsertRowNumber.value)">
</form>
</body>
</html>
=============================================================
row by a javascript.
The following code (javascript) works with the Internet Explorer and also
with Mozilla. However, the inserted button (onClick) in the table does not
work with the Internet Explorer. It only works with Mozilla.
I'm trying the whole Sunday without any success.
Please give me a hint.
Stefan
PS: It seems that also the width-statement (width:75) is not working with
the Internet Explorer.
=============================================================
<html>
<script type="text/javascript">
function InsertRow(WhereToInsert) {
var xtable
var xrow
var xcell
var xelement
xtable = document.getElementById("MyTable")
xrow = xtable.insertRow(WhereToInsert)
xcell = xrow.insertCell(0)
xcell.innerHTML = "Inserted Row"
xcell.setAttribute("bgColor", "#008888")
xcell = xrow.insertCell(1)
xcell.innerHTML = ""
xcell.setAttribute("bgColor", "#008888")
xelement = document.createElement("input")
xelement.setAttribute("type", "button")
xelement.setAttribute("style", "width:75")
xelement.setAttribute("value", "Click")
xelement.setAttribute("onClick", "alert('Wow, it works!')")
xcell.appendChild(xelement)
}
</script>
<body>
<form name="MyForm">
<table id = "MyTable" width = "400" align = "center">
<tr>
<td width = "50%" style = "background-color:#00ffff">
Text Row 1
</td>
<td width = "50%" style = "background-color:#00ffff">
<input type = "button" style = "width:75" value = "Click"
onClick = "alert('Wow, it works!')">
</td>
</tr>
<tr>
<td width = "50%" style = "background-color:#00ffff">
Text Row 2
</td>
<td width = "50%" style = "background-color:#00ffff">
<input type = "button" style = "width:75" value = "Click"
onClick = "alert('Wow, it works!')">
</td>
</tr>
</table>
<p>
Where to insert the new row:
<input type = "text" name = "InsertRowNumber" value = "">
<input type = "button" value = "Add Row" onClick =
"InsertRow(document.MyForm.InsertRowNumber.value)">
</form>
</body>
</html>
=============================================================