Put these two javascript functions in script tag under head section of your page:
function findParentForm(elem){
var parent = elem.parentNode;
if(parent && parent.tagName != 'FORM'){
parent = findParentForm(parent);
}
return parent;
}
function getParentForm( elem )
{
var parentForm = findParentForm(elem);
if(parentForm){
alert("Form found: ID = " + parentForm.id + " & Name = " +parentForm.name);
}else{
alert("unable to locate parent Form");
}
}
Here is the example to call this code:
<body>
<h3> Form 1 </h3>
<form name ="formName1" id ="formId1">
<span>
<div>
<input type ="button" name ="button1" value="button1" onclick="javascript:getParentForm(this);"/> <br/>
</div>
</span>
</form>
<hr/>
<h3> Form 2 </h3>
<form name ="FormName2" id ="formId2">
<span>
<div id ="asda" name ="divName">
<input type ="button" name ="button1" value="button2" onclick="javascript:getParentForm(this);"/> <br/>
</div>
</span>
</form>
</body>
18 comments:
or just use this.form :)
Hi! That's an awesome blog. Recently I completed Javascript Training in Chennai and I am doing a project now. I came across a similar situation like yours. Thanks for sharing. This'll really help me out.
Javascript Training Courses | Javascript Training | Javascript Training Institute in Chennai
I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!
python Training in Pune
python Training in Chennai
python Training in Bangalore
Reading your blog left me with some useful info and this was an awesome blog.
Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Best Spoken English Classes in Chennai
Best Spoken English Institute in Chennai
Well you use a hard way for publishing, you could find much easier one!
Data Science Training in Chennai
Data Science training in kalyan nagar
Data science training in Bangalore
Data Science training in marathahalli
Data Science interview questions and answers
Data science training in bangalore
Articles are inspiring,Great Information's are shared here.I look forward to your writing
python training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery
Appreciated For the Persistence of your Work...Keep Sharing
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Java training in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Online Training
The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.data science course in HyderabadThe strategy you have posted on this technology helped me to get into the next level and had lot of information in it.data science course in Hyderabad
I really have to search sites with relevant information on given topic and provide them to teacher our opinion and the article.thanks a lot,
data science training in chennai
data science training in tambaram
android training in chennai
android training in tambaram
devops training in chennai
devops training in tambaram
artificial intelligence training in chennai
artificial intelligence training in tambaram
Thanks for sharing this unique information with us. Your post is really awesome. Your blog is really helpful for me..
angular js training in chennai
angular js training in annanagar
full stack training in chennai
full stack training in annanagar
php training in chennai
php training in annanagar
photoshop training in chennai
photoshop training in annanagar
Reading your blog left me with some useful info and this was an awesome blog.
web designing training in chennai
web designing training in omr
digital marketing training in chennai
digital marketing training in omr
rpa training in chennai
rpa training in omr
tally training in chennai
tally training in omr
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
data scientist training and placement in hyderabad
This post is so interactive and informative.keep update more information...
RPA Training in Tambaram
RPA Training in Chennai
Such a helpful article. Interesting to peruse this article.I might want to thank you for the endeavors you had made for composing this wonderful article.
best data science training in hyderabad
Nice blog and informative content. Really useful for many people, I bookmarked your website for further blogs. Thanks, you.
Data Science Course with Placements in Hyderabad
This post is so interactive and informative.keep update more information…
SEO Training in Anna Nagar
SEO Training in Chennai
Very informative blog thanks sharing with us
Building Contractors in Chennai
Post a Comment