一个页面有两个form本身就有问题吧?

解决方案 »

  1.   

    暈,你本身代碼不規範,流覽器會在解析html的時候自動進行一些操作(補全結束標籤啊撒的),你可以在firefox里用firebug查看一下頁面的html代碼你就知道了以下是你的代碼在firefox里真正的結構<body>
    <form class="map2" name="appForm" id="testForm">
    <input type="hidden" value="p_Customer" name="appForm_RootElem">
    <input type="hidden" value="CstGUID" name="appForm_KeyName">
    <input type="hidden" value="Default" name="appForm_AppName">
    </form>
    <table width="100%" height="100%" cellspacing="0" cellpadding="0">
    <form class="map2" name="appForm" id="testForm2"></form>
    <input type="hidden" value="p_Customer" name="appForm_RootElem">
    <input type="hidden" value="CstGUID" name="appForm_KeyName">
    <input type="hidden" value="Default" name="appForm_AppName">

    </table>
    </body>
      

  2.   

    这并不是所谓的bug,而是由于你的标签嵌套不规范所致,也就是所谓的前端规范比如 拥有子父级关系的标签 如 ul li 理论上 ul 下可以嵌套除了li以外的任何标签,可是直接会影响到 js中 读取节点,由于结果混乱而导致节点混乱,根据节点的概念,认为你ul下只可能是li,否则 则会产生读取节点错误或者读取不到修改如下<table width="100%" height="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><form id="testForm2" name="appForm" class="map2">
            <input type="hidden" name="appForm_RootElem" value="p_Customer"/>
            <input type="hidden" name="appForm_KeyName" value="CstGUID"/>
            <input type="hidden" name="appForm_AppName" value="Default"/>
          </form></td>
      </tr>
    </table>
      

  3.   

    的确是啊,我帮你顶n顶。
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body><form id="testForm" name="appForm" class="map2">
    <input type="hidden" name="appForm_RootElem" value="p_Customer" /> <input type="hidden" name="appForm_KeyName" value="CstGUID" /> <input type="hidden" name="appForm_AppName" value="Default" />
    </form>
    <table width="100%" height="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <form id="testForm2" name="appForm" class="map2">
    <input type="hidden" name="appForm_RootElem" value="p_Customer" /> <input type="hidden" name="appForm_KeyName" value="CstGUID" /> <input type="hidden" name="appForm_AppName" value="Default" />
    </form>
    </td>
    </tr>
    </table><script>
    var $a = document.getElementById('testForm2');
    var $b = $a.querySelectorAll("[id='testForm'] input");</script></body>
    </html>
      

  4.   

    haha ,是不规范啊。
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body><form id="testForm" name="appForm" class="map2">
    <input type="hidden" name="appForm_RootElem" value="p_Customer" /> <input type="hidden" name="appForm_KeyName" value="CstGUID" /> <input type="hidden" name="appForm_AppName" value="Default" />
    </form>
    <table width="100%" height="100%" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <form id="testForm2" name="appForm" class="map2">
    <input type="hidden" name="appForm_RootElem" value="p_Customer" /> <input type="hidden" name="appForm_KeyName" value="CstGUID" /> <input type="hidden" name="appForm_AppName" value="Default" />
    </form>
    </td>
    </tr>
    </table><script>
    var $a = document.getElementById('testForm2');
    var $b = $a.querySelectorAll("[id='testForm2'] input");</script></body>
    </html>
      

  5.   

    有两个form没什么问题,而且就算有问题我也改不了,前端HTML代码是第三方的,我只能写JS插件。