Hi....
With jQuery you can use .closest() or .parent() (though parent only looks up 1 level, whereas .closest() goes up until it find something). I've always found .closest() easier and more robust, as it will work if you change the markup (i.e. you wrap stuff in a <span> or something).
Anyways, here's the jQuery version:
<input type="radio" onlick="var id = $(this).closest('table').attr('id');" />
If you don't use a library, you can do this with just JavaScript as well.
The JavaScript:
function findAncestorByTagName(start, tagName) {
if (tagName.toUpperCase() === start.nodeName.toUpperCase()) {
return start;
}
else if (start === document.body) {
return false;
}
else {
return findAncestorByTagName(start.parentNode, tagName);
}
}
The onclick handler you'll have to add:
<input type="radio" onclick="var par = findAncestorByTagName(this, 'div'); if (par && par.id) { /* use par.id */ }" />