Hi.. i am new to javascripts,
i am using a addRow scipt to add rows to a table dynamically.
one of the cells(say cell2) in a Nth row needs to be hyperlinked to another script.
for example:
[code=javascript]
function addRow() // the add row script
{
var tbl=document.ge tElementById("t able");
var numRows=tbl.row s.length;
var newRow=tbl.inse rtRow(numRows);
//IDs
var secondCell=newR ow.insertCell(2 );
var box2=document.c reateElement('T D');
//textbox
var txtInp2=documen t.createElement ('input');
txtInp2.name="I Ds";
txtInp2.type='t ext';
txtInp2.value=" ";
//image
var link2=document. createElement(' <a href="#"onClick ="javascript:Po pup(this)">');
var image2=document .createElement( '<IMG align=middle border=0 src='find.gif'> ');
link2.appendChi ld(image2);
box2.appendChil d(txtInp2);
box2.appendChil d(link2);
secondCell.appe ndChild(box2);
// i am appending image to link , txtInp2 and link to the box, and box2 to //secondCell.
}
function Popup(obj)
{
currentRowIndex = obj.parentEleme nt.parentElemen t.rowIndex;
obj = document.form.I Ds;
if(obj.length != null)
{
window.Id=docum ent.form.IDs(cu rrentRowIndex-1);
}
else
{
window.Id=obj;
}
var urlString = <something>;
image=window.op en(urlString,"w idth=480,height =230,status");
image.focus();
}
[/code]
My problem is, if the table is already defined(if href to PopUp() specified in first row of table,declared in HTML, then link to PopUp(obj) is working , but if i add rows to the table dynamically using addRow(), the links to PopUp() in the new rows added are not working,
it gives a error msg telling either "object expected" or "parentElement. parentElement" ,or "length is null or not an object"
I dont know how to specify the 'this' in
var link2=document. createElement(' <a href="#"onClick ="javascript:Po pup(this)">');
PLZ help...!
i am using a addRow scipt to add rows to a table dynamically.
one of the cells(say cell2) in a Nth row needs to be hyperlinked to another script.
for example:
[code=javascript]
function addRow() // the add row script
{
var tbl=document.ge tElementById("t able");
var numRows=tbl.row s.length;
var newRow=tbl.inse rtRow(numRows);
//IDs
var secondCell=newR ow.insertCell(2 );
var box2=document.c reateElement('T D');
//textbox
var txtInp2=documen t.createElement ('input');
txtInp2.name="I Ds";
txtInp2.type='t ext';
txtInp2.value=" ";
//image
var link2=document. createElement(' <a href="#"onClick ="javascript:Po pup(this)">');
var image2=document .createElement( '<IMG align=middle border=0 src='find.gif'> ');
link2.appendChi ld(image2);
box2.appendChil d(txtInp2);
box2.appendChil d(link2);
secondCell.appe ndChild(box2);
// i am appending image to link , txtInp2 and link to the box, and box2 to //secondCell.
}
function Popup(obj)
{
currentRowIndex = obj.parentEleme nt.parentElemen t.rowIndex;
obj = document.form.I Ds;
if(obj.length != null)
{
window.Id=docum ent.form.IDs(cu rrentRowIndex-1);
}
else
{
window.Id=obj;
}
var urlString = <something>;
image=window.op en(urlString,"w idth=480,height =230,status");
image.focus();
}
[/code]
My problem is, if the table is already defined(if href to PopUp() specified in first row of table,declared in HTML, then link to PopUp(obj) is working , but if i add rows to the table dynamically using addRow(), the links to PopUp() in the new rows added are not working,
it gives a error msg telling either "object expected" or "parentElement. parentElement" ,or "length is null or not an object"
I dont know how to specify the 'this' in
var link2=document. createElement(' <a href="#"onClick ="javascript:Po pup(this)">');
PLZ help...!
Comment