已知 html元素 HtmlElement he;
求 元素he所在表单的name,既he所在的form表单的名称。

解决方案 »

  1.   

    用js获取指定元素的父元素
    window.document.getElementById("123").parentNode
      

  2.   

    谢谢 南宫------脱条裤衩给我。。hoho我现在的思路是用递归,不知道有没有更好的方法。 public static HtmlElement GetHtmlElementParentForm(HtmlElement he)
            {
                HtmlElement heParent = he.Parent;
                string tagName = heParent.TagName.ToUpper();
                if (tagName == "BODY" || tagName = "HTML") return null;
                if (tagName == "FORM" || tagName == "IFRAME") return heParent;
                return GetHtmlElementParentForm(heParent);
            }
      

  3.   

    如果你只有一个表单
    window.document.forms来获取:)
    不用脱我裤衩了...我来脱你的吧...分给我:D
      

  4.   

    又有新问题出现了,有时候取回的FORM元素的Name="mshtml.HTMLInputElementClass" 
    但在html代码里查看这个FORM的Name明明为form,
    即<FORM name="form" action=".....">......</FORM>
      

  5.   

    才20分,我不干哟,强烈要求加分!
    try this
    function getfather(xx)
     {
       //window.alert('ok');
       if(xx.parentNode!=null)
       {
            window.alert(xx.parentNode.nodeName);
                    getfather(xx.parentNode);
       }
        
     }