Finding ids using javascript

Hi javascript gurus,

I have a table with a structured as below. What I want to do is place the id abc into an array like so myarray=[a,b,c];
I know that document.getElementById goes to the table called waterloo and getElementsByTagName(‘td’) gets all the tds
then I am looping over them all. All the alert gives me are three commas like so ,

Any help would be great


<table id="waterloo">
<tr>
         <td id="a"></td>
         <td id="b"></td>
          <td id="c"></td>
</tr>
</table>
<script>
   var  myTdId =[];
    
	var x= document.getElementById(formId).getElementsByTagName('td');

	for (var i=0; i<x.length; i++) {
   	    if (x[i].hasOwnProperty) {
                   myTdId.push(temp[i]);
  		}
	}
          alert (myTdId);
</script>


var x= document.getElementById(formId).getElementsByTagName('td');

The above line is getting the td’s only from within the element whose id = formId. What is the value of formId?

Also, where is temp[i] defined in your code?

Thanks for the relpy

Sorry formId is waterloo and I change x now I get the following in the alert box

[object HTMLTableCellElement],
[object HTMLTableCellElement],
[object HTMLTableCellElement],


    var formId="waterloo"
    var  myTdId =[];
    
	var x= document.getElementById(formId).getElementsByTagName('td');

	for (var i=0; i<x.length; i++) {
  	    if (x[i].hasOwnProperty) {
                   myTdId.push(x[i]);
  		}
	}
         alert (myTdId);


you’re not using hasOwnPeoperty correctly.