SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    Denver
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get parent form node

    Greetings, Is there a way for me to get to the parent <form> node from an element node?

    <form id="frm1">
    <input id="myinput" type="text" value="myval" />
    </form>

    <script>
    var myinput = document.getElementById('myinput');

    //can I get a hold of <form id="frm1"> using myinput?
    </script>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,268
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    parent

    Did you try
    myinput.parentNode ??

    EDIT: maybe this will help
    http://developer.mozilla.org/en/docs/DOM:form

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    form elements all have a form property, which refers to their containing form.
    Note that you can't include a form in another form.

    var formreference=myinput.form;

  4. #4
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    Denver
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mrhoo, that's what I'm looking for. thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •