I have the following html snippet
<table>
<tr>
<td><select name="day">
</select></td>
<td><select name="time">
</select></td>
<td><select name="closed" onchange="dosomething(this)">
</select></td>
</tr>
</table>
When i change something on , then i would like to get a handle to and do some operation on it. How do i get a handle to in javascript?
function closedChanged(object)
{
try
{
var parent=object.parentNode.parentNode;
var day = parent.getElementsByName("day")[0];
}
catch(e)
{
alert(e);
}
}
Here i am getting error saying that HTMLTableRowElement does not have method called getElementsByName. Any other way?
You could also try getting all select elements, looping through them and checking their name:
I’m sure it’s similar to what document.getElementsByName() does but not searching by tag first.