我用 innerHTML 生成 表单,然后提交。
在IE下正常。。在遨游下。表单数据提交无效。
脚本代码如下:
var tb=document.getElementById("writeBigSort");
Bightml += '<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" class="STYLE1"><tr bgcolor="#FFFFFF"><td height="22" bgcolor="#FFFFFF" width="5%"><textarea name="small_sort[]" cols="20" rows="1" onFocus="this.rows=2;" onBlur="this.rows=1;" style="background-color:#7AC2D8" ></textarea></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><textarea name="bud_project[]" cols="44" rows="1" onFocus="this.rows=2;" onBlur="this.rows=1;"></textarea></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_price[]" value="" size="10"/></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_allNum[]" value="0" size="10" /></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_allMonery[]" value="0" size="10" /></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_ready[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><input name="bud_account[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><input name="bud_settle[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%">';
Bightml += '<input name="button2" type="button" value="新增行" class="button" onClick="AddSmallSort();";/></td></tr>';
tb.innerHTML=Bightml;
在IE下正常。。在遨游下。表单数据提交无效。
脚本代码如下:
var tb=document.getElementById("writeBigSort");
Bightml += '<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#c9c9c9" class="STYLE1"><tr bgcolor="#FFFFFF"><td height="22" bgcolor="#FFFFFF" width="5%"><textarea name="small_sort[]" cols="20" rows="1" onFocus="this.rows=2;" onBlur="this.rows=1;" style="background-color:#7AC2D8" ></textarea></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><textarea name="bud_project[]" cols="44" rows="1" onFocus="this.rows=2;" onBlur="this.rows=1;"></textarea></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_price[]" value="" size="10"/></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_allNum[]" value="0" size="10" /></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_allMonery[]" value="0" size="10" /></td>';
Bightml += '<td bgcolor="#FFFFFF" width="5%"><input type="text" name="bud_ready[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><input name="bud_account[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%"><input name="bud_settle[]" value="0" size="10" /></td>';
Bightml += '<td height="22" bgcolor="#FFFFFF" width="5%">';
Bightml += '<input name="button2" type="button" value="新增行" class="button" onClick="AddSmallSort();";/></td></tr>';
tb.innerHTML=Bightml;
是一个什么东西
问题是,我所在的公司 他们用的都是 遨游。郁闷啊。
<input type="text" name="bud_allNum[]" value="0" size="10" />有没有可能是由于 多个名称 为 bud_allNum[] 这个导致的?
因为这个转换成PHP变量 就成了 $bud_allNum[] 这种形式, 这个就是个数组。
Bightml += '<input name="button2" type="button" value="新增行" class="button" onClick="AddSmallSort();";/></td></tr></table>';
将form 移到table 外就可以了。
原先是写成这样
<form...>
<tr>
.......
</tr>
</form>
改为
<form...>
<table>
<tr>
.......
</tr>
</table>
</form>就可以了!