ysre
asked on
Finding an <input>'s <form>-parent via DOM?
Hi,
I'm just wondering..
How would you walk the DOM-tree in order to find the parent <FORM> element (eg. to submit() it) of any given <INPUT> element?
Example:
<form action="sth"> <!-- no name or id or class! -->
<input type="text" onClick="alert (find_parental_form_elemen t(this))">
<input type="text" onClick="alert (find_parental_form_elemen t(this))">
<input type="text" onClick="alert (find_parental_form_elemen t(this))">
</form>
Walking via .parentNode only returns me styling - type elements (eg. in this order: DIV, TD, TR, TBODY, TABLE).
Ys
I'm just wondering..
How would you walk the DOM-tree in order to find the parent <FORM> element (eg. to submit() it) of any given <INPUT> element?
Example:
<form action="sth"> <!-- no name or id or class! -->
<input type="text" onClick="alert (find_parental_form_elemen
<input type="text" onClick="alert (find_parental_form_elemen
<input type="text" onClick="alert (find_parental_form_elemen
</form>
Walking via .parentNode only returns me styling - type elements (eg. in this order: DIV, TD, TR, TBODY, TABLE).
Ys
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hm yeah, I added some prerequisites (that's why I called it quirky).
Just wanted to find out if you can do it via the appraised ;) DOM 1 model.
Apparently you can't really.
Unless you use the old-style document.forms approach (or getElementsByTagName for firefox).
Thanks for the insight :)
Just wanted to find out if you can do it via the appraised ;) DOM 1 model.
Apparently you can't really.
Unless you use the old-style document.forms approach (or getElementsByTagName for firefox).
Thanks for the insight :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmpf sometimes things can be so easy..
Funny it never showed up in the properties' listing for the element(s).
Thanks :)
Funny it never showed up in the properties' listing for the element(s).
Thanks :)
ASKER
I'm walking back via .parentNode until I find a node that has a childnode which has a nodeName of "FORM" ;)
Ys