sc**********@gmail.com said on 21/03/2006 8:10 AM AEST:
I figured this out, and wanted to help anyone that might stumble on
this post
try document.getElementById('dgrList').rows
Note Thomas' reply, some (most?) browsers don't provide a click method
for all elements even though they support the onclick attribute.
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-2651361>
If rowRef is a reference to a row, then rowRef.click() may 'work' in
some browsers (e.g. IE), but not others (e.g. Firefox). You need to use
createEvent to attach the event so you can click on it.
<script type="text/javascript">
function clickOn(id)
{
var el;
if ( document.getElementById
&& (el = document.getElementById(id))){
// Create an event object
if ( document.createEvent ){
var eventObj = document.createEvent("MouseEvent");
// Initialise properties
eventObj.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
// Run the event
if (el.dispatchEvent) el.dispatchEvent(eventObj);
} else if (el.click) {
el.click();
}
}
}
function sayHi(){alert('hi');}
</script>
<input type="button" value="Attach click"
onclick="clickOn('tr01');">
<table border="1">
<tr id="tr01" onclick="sayHi();">
<td>Click the button to fire the onclick event</td>
</tr>
</table>
--
Rob