sumanreddy
02-04-2005, 08:06 AM
hai
the following code is working in Internet Explorer, but not working in Opera. Pls Check the code and give the solution, so that it should work in Opera Browser.
<html>
<head>
<script type="text/javascript">
var i=0;
function insRow()
{
var trow=document.getElementById('myTable').insertRow()
var tdata1=trow.insertCell(0)
var tdata2=trow.insertCell(1)
var tdata3=trow.insertCell(2)
var tdata4=trow.insertCell(3)
var tdata5=trow.insertCell(4)
tdata1.innerHTML="<input type='text' id='txt' >"
tdata2.innerHTML="<input type='CHECKBOX' id='chk'>"
tdata3.innerHTML="<textarea id='tarea'></textarea>"
tdata4.innerHTML="<select id='lov'></select>"
tdata5.innerHTML="<input type='button' id='btn' onclick=delrow(this)>"
document.forms[0].elements[i].id=document.forms[0].elements[i].id+i;
document.forms[0].elements[i+1].id=document.forms[0].elements[i+1].id+i;
document.forms[0].elements[i+2].id=document.forms[0].elements[i+2].id+i;
document.forms[0].elements[i+3].id=document.forms[0].elements[i+3].id+i;
document.forms[0].elements[i+4].id=document.forms[0].elements[i+4].id+i;
tname="txt"+i;
chkname="chk"+i;
tareaname="tarea"+i;
lovname="lov"+i;
btnname="btn"+i;
tid="txt"+i;
chkid="chk"+i;
tareaid="tarea"+i;
lovid="lov"+i;
btnid="btn"+i;
var txtid = document.getElementById(tid);
txtid.setAttribute("name",tname);
var chkid = document.getElementById(chkid);
chkid.setAttribute("name",chkname);
var tareaid = document.getElementById(tareaid);
tareaid.setAttribute("name",tareaname);
var lovid = document.getElementById(lovid);
lovid.setAttribute("name",lovname);
var btnid = document.getElementById(btnid);
btnid.setAttribute("name",btnname);
btnid.setAttribute("value","delete row");
i=i+5;
}
function delrow(curr_row)
{
document.getElementById('myTable').deleteRow(curr_row.parentNode.parentNode.rowIndex);
}
</script>
</head>
<body>
<form>
<table id="myTable" border="1">
</table>
<input type="button" onclick="insRow()" value="Insert row">
</form>
</body>
</html>
the following code is working in Internet Explorer, but not working in Opera. Pls Check the code and give the solution, so that it should work in Opera Browser.
<html>
<head>
<script type="text/javascript">
var i=0;
function insRow()
{
var trow=document.getElementById('myTable').insertRow()
var tdata1=trow.insertCell(0)
var tdata2=trow.insertCell(1)
var tdata3=trow.insertCell(2)
var tdata4=trow.insertCell(3)
var tdata5=trow.insertCell(4)
tdata1.innerHTML="<input type='text' id='txt' >"
tdata2.innerHTML="<input type='CHECKBOX' id='chk'>"
tdata3.innerHTML="<textarea id='tarea'></textarea>"
tdata4.innerHTML="<select id='lov'></select>"
tdata5.innerHTML="<input type='button' id='btn' onclick=delrow(this)>"
document.forms[0].elements[i].id=document.forms[0].elements[i].id+i;
document.forms[0].elements[i+1].id=document.forms[0].elements[i+1].id+i;
document.forms[0].elements[i+2].id=document.forms[0].elements[i+2].id+i;
document.forms[0].elements[i+3].id=document.forms[0].elements[i+3].id+i;
document.forms[0].elements[i+4].id=document.forms[0].elements[i+4].id+i;
tname="txt"+i;
chkname="chk"+i;
tareaname="tarea"+i;
lovname="lov"+i;
btnname="btn"+i;
tid="txt"+i;
chkid="chk"+i;
tareaid="tarea"+i;
lovid="lov"+i;
btnid="btn"+i;
var txtid = document.getElementById(tid);
txtid.setAttribute("name",tname);
var chkid = document.getElementById(chkid);
chkid.setAttribute("name",chkname);
var tareaid = document.getElementById(tareaid);
tareaid.setAttribute("name",tareaname);
var lovid = document.getElementById(lovid);
lovid.setAttribute("name",lovname);
var btnid = document.getElementById(btnid);
btnid.setAttribute("name",btnname);
btnid.setAttribute("value","delete row");
i=i+5;
}
function delrow(curr_row)
{
document.getElementById('myTable').deleteRow(curr_row.parentNode.parentNode.rowIndex);
}
</script>
</head>
<body>
<form>
<table id="myTable" border="1">
</table>
<input type="button" onclick="insRow()" value="Insert row">
</form>
</body>
</html>