Getting the id of a Form which contains a table

A

Abdullah Kauchali

Is it possible to obtain the id of the immediate FORM given the id of a
table which is situated within the form?

<form id=myform>
<table id=mytable onclick=getFormId(??)>
</table>
</form>

Many thanks in advance,

Abdullah
 
J

Janwillem Borleffs

Abdullah said:
Is it possible to obtain the id of the immediate FORM given the id of
a table which is situated within the form?

<form id=myform>
<table id=mytable onclick=getFormId(??)>
</table>
</form>

function getFormId(id) {
var object = document.getElementById(id);
while (object && (object.tagName != "FORM") && (object =
object.parentNode));
if (object && object.id) alert(object.id);
}
....
<form id="myform">
<table id="mytable" onclick="getFormId(id)">
....
</table>
</form>


JW
 
A

Abdullah Kauchali

function getFormId(id) {
var object = document.getElementById(id);
while (object && (object.tagName != "FORM") && (object =
object.parentNode));
if (object && object.id) alert(object.id);
}

Shot!! <g> Have great weekend!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top