Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Firefox中,insertRow()在javascript中不起作用_Javascript_Jsp_Firefox_Html_Cross Browser - Fatal编程技术网

在Firefox中,insertRow()在javascript中不起作用

在Firefox中,insertRow()在javascript中不起作用,javascript,jsp,firefox,html,cross-browser,Javascript,Jsp,Firefox,Html,Cross Browser,我在一个JSP文件中工作。在这种情况下,我需要创建一个带有多行onclick事件的表。当我在IE7和IE8中尝试以下代码时,它运行良好。但当我在Firefox中尝试同样的方法时(在任何版本中),它并没有创建表 这是我需要创建的div部分 <div id="acc" style="display:none" width="90%"> <table border=0 cellpadding=1 cellspacing=1 width="97%" align="center"

我在一个JSP文件中工作。在这种情况下,我需要创建一个带有多行onclick事件的表。当我在IE7和IE8中尝试以下代码时,它运行良好。但当我在Firefox中尝试同样的方法时(在任何版本中),它并没有创建表

这是我需要创建的div部分

<div id="acc" style="display:none" width="90%">
    <table border=0 cellpadding=1 cellspacing=1 width="97%" align="center">
        <tr>
            <td class="txnSubHdrBg">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td nowrap>Account Details</td>
                        <td align="right">
                        <table border="0" cellspacing="0" cellpadding="0">
                          <tr>                            
                            <td style="padding-right:2px;" valign="top"><a href="javascript:void(0)"><img src="/images/add_account_but.jpg" border="0"  alt="Add account credit details" onclick="return addAccountRow(); return false;"/></a></td>
                          </tr>
                        </table>
                        </td>
                    </tr>
                </table>                            
            </td>
        </tr>
    </table>
    <% int rowId=0;%>
    <table border=0 cellpadding=1 cellspacing=1 width="97%" id="AccountList" align="center" > 
        <logic:iterate name="xMBeneficiaryRegistrationForm"  property="beneficiaryAccountList" id="row">                            
            <tr><td>
                <table cellpadding=0 cellspacing=6 width="100%">
                <tr>

                    <html:hidden name="row" property="accountSerialNo"/>
                    <td class="fieldLabel" width="180"><bean:message key="XpressMoney.Xpress.AccountName"/></td>
                    <td class="fldtxt">
                        <html:text name="row"  property="accountName" styleClass="fieldText" size="20"  tabindex="27" style="width:167px" title="Input Account Name" onkeypress="return AcceptableCharsforAddress(event); return false;"/>
                        <span class="fieldLabel" ><bean:message key="label.mamStatus"/></span>
                        <html:select property="accountStatusDisplay" tabindex="28" styleClass="fieldText" size="1">
                        <html:option value="1"><bean:message key="XpressMoney.XM.Enable"/></html:option>
                        <html:option value="1073741824"><bean:message key="XpressMoney.XM.Disable"/></html:option>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td class="fieldLabel"><bean:message key="XpressMoney.Xpress.AccountNo"/></td>
                    <td class="fldtxt">
                        <html:text name="row"  property="accountNo" tabindex="29" styleClass="fieldText" onkeypress="return AcceptCharsandNumbers(event)" style="width:167px;padding:0 0 0 3px"  size="20" title="Input Account No"/>
                    </td>
                </tr>                                   
                <tr>
                    <td align="left" class="fieldLabel">Bank Name</td>
                    <td class="fldtxt"> 
                    <input type="hidden" name="beneficiaryBankTemp" value=<bean:write name="row"  property="beneficiaryBank"/>>
                    <select class="fieldText" style="width:250px" name="beneficiaryBank" onchange="retrieveDestinationBeneficiaryBankName(<%=rowId%>)" >
                         <option value="0">--select Bank--</option>
                    </select>   
                    </td>
                </tr>                           
                <tr>
                    <td align="left" class="fieldLabel">Beneficiary Bank</font></td>
                    <td class="fldtxt"> 
                    <input type="hidden" name="beneficiaryBankNameTemp" value=<bean:write name="row"  property="beneficiaryBankName"/>>                                         
                    <select class="fieldText" style="width:250px" name="beneficiaryBankName" onchange="setSelectedBankValuesToHidden();">
                         <option value="0">--select Beneficiary Bank--</option>
                    </select>
                    </td>

                </tr>                   


                </table>
            </td>
            </tr>
        </logic:iterate>                
    </table>
    <%rowId++;%>
如何使其与Firefox兼容?

使用

var tr = document.createElement("TR");
AccountListTable.rows.append(tr)

使用

见:

如果索引被省略或大于行数,则将出现错误 结果

我建议使用像jQuery这样的跨浏览器JavaScript库,无论浏览器是什么,它都可以工作。

请参阅:

如果索引被省略或大于行数,则将出现错误 结果

我建议使用像jQuery这样的跨浏览器JavaScript库,无论浏览器是什么,它都可以工作。

我会使用jQuery:

有一个类似的问题,使用JQuery给出了答案:

如果不能使用JQuery,请告知我们。

我会使用JQuery:

有一个类似的问题,使用JQuery给出了答案:

如果不能使用JQuery,请告知我们。

请参阅

您应该在FF/XUL中使用DOM方法。检查上面的链接,那里给出的代码在IE&FF中运行良好

甚至,我建议您使用jQuery是最值得推荐的一种

您应该在FF/XUL中使用DOM方法。检查上面的链接,那里给出的代码在IE&FF中运行良好

甚至,我建议您使用jQuery是最值得推荐的方法。

这里有一个解决方案:

var row = infoTable.insertRow(-1);
var cell = document.createElement("td");
cell.innerHTML = " ";
cell.className = "XXXX";
row.appendChild(cell); 
以下是一个解决方案:

var row = infoTable.insertRow(-1);
var cell = document.createElement("td");
cell.innerHTML = " ";
cell.className = "XXXX";
row.appendChild(cell); 

如果您需要帮助,您应该接受前面问题的答案(单击最佳答案左侧的勾号)。如果你不关心给你的答案,我们为什么会关心你的新问题?对不起,JMax。我对这个stackoverflow很陌生。一旦我得到预期的结果,我当然会打勾。你也可以看看你以前的问题(点击签名中的你的名字,找到你的整个活动)并接受这些答案,回答您的用户可能正在等待。此外,这有助于进一步研究,因为接受的答案会首先显示。您发布的代码太多;您应该尝试隔离问题。如果我是正确的,您甚至使用了struts标记;这样,它(几乎)是我不可能尝试一些东西并测试它来帮助您。您应该尝试的一件事是:insertRow(-1);这在所有常用浏览器中都有效;它在表格中插入一行作为最后一行。2015年末仍然没有被接受的答案?如果您需要帮助,您应该接受以前问题的答案(单击最佳答案左侧的勾号)。如果你不关心给你的答案,我们为什么会关心你的新问题?对不起,JMax。我对这个stackoverflow很陌生。一旦我得到预期的结果,我当然会打勾。你也可以看看你以前的问题(点击签名中的你的名字,找到你的整个活动)并接受这些答案,回答您的用户可能正在等待。此外,这有助于进一步研究,因为接受的答案会首先显示。您发布的代码太多;您应该尝试隔离问题。如果我是正确的,您甚至使用了struts标记;这样,它(几乎)是我不可能尝试一些东西并测试它来帮助您。您应该尝试的一件事是:insertRow(-1);这在所有常用浏览器中都有效;它在表中插入一行作为最后一行。2015年末仍然没有被接受的答案?我不能使用JQuery,我只需要使用javascript。还有什么其他技巧吗?我也尝试过你的方法,同样的问题只记录了。你能给我tbody的示例吗?我需要在div部分或addrow中添加tbody吗nction?尝试向元素添加以下样式。行的display='table-row'和单元格的display='table cell',我不能使用JQuery,我只需要使用javascript。还有其他技巧吗?hungryMind我也尝试过你的方法,同样的问题只记录了。你能给我tbody的示例吗?我需要在那个div部分或addrow f中添加tbody吗函数?尝试将以下样式添加到元素中。行的显示='table-row',单元格的显示='table cell'
var row = infoTable.insertRow(-1);
var cell = document.createElement("td");
cell.innerHTML = " ";
cell.className = "XXXX";
row.appendChild(cell);