i need to get the values of the cell in the same row when i click the cell. the table is generated using document.write.

sample code

<script type="text/javascript">
function cmsSearch(){
var winnew = window.open("result.html", "result", status)
winnew.document.write("<table>");
winnew.document.write("<tr>");
winnew.document.write("<td onclick='getVal(this)'>xxx</td>");
winnew.document.write("<td>yyy</td>");
winnew.document.write("</tr>");
winnew.document.write("</table>");
}

function getVal(e){
var row= e.parentNode;
var s= "";
for(var i=0; i<row.cells.length;i++){
s+= row.cells[i].innerText;
}
alert(s);
}

when i click cell that has a value of xxx, xxx and yyy will be used as arguments to function getVal(). problem is runtime error occura and it needs an object. what seems to be the problem?