Php 将Jquery添加的html元素发布到表单

Php 将Jquery添加的html元素发布到表单,php,jquery,html,post,Php,Jquery,Html,Post,我有一个表和两个按钮来添加和删除一组通过Jquery动态添加的html元素。当我提交表格时。操作页面仅打印手动编码的表单元素 我已经做了这件事 $('myTable tr:last')。在(newElem)之后 在jQuery中 以下是链接www.jsfiddle.net/abelkbil/3GbWH/3/ 结果是这样的 数组([rno]=>123[adno]=>Array([0]=>1235它没有打印[1]=>x)[rel 感谢所有支持html中未关闭表单标记。它还应包含两个嵌套表 &

我有一个表和两个按钮来添加和删除一组通过Jquery动态添加的html元素。当我提交表格时。操作页面仅打印手动编码的表单元素

我已经做了这件事 $('myTable tr:last')。在(newElem)之后

在jQuery中

以下是链接www.jsfiddle.net/abelkbil/3GbWH/3/

结果是这样的

数组([rno]=>123[adno]=>Array([0]=>1235它没有打印[1]=>x)[rel


感谢所有支持

html中未关闭
表单
标记。它还应包含两个嵌套表

    <form name="f10"  id="myform" method=POST action="http://testxml.net84.net/abel-test/test.php">
    <table id="myTable">
    <tbody>
    <tr><th><th><th><th><th>Ration Number</th><td><input type="text" name="rno"></td><th>Grand total</th><td><input type="text" name="adno[0]"></td></tr>
    <tr><th>Aadaar Number</th><th>Relationship</th><th>Income from land</th><th>Salary/Pension</th><th>Income from business</th><th>Income from Labour</th><th>Rental Income</th><th>Any other income</th><th>total
    </th></tr>
    <input type="hidden" id="rowcount" value="1" >
    <tr><td><input type="text" name="adno[0]"></td>
    <td>
    <select name="relation">
    <option  value="owner">owner</option>
    <option  value="Father">Father </option>
    <option  value="Mother">Mother</option>
    <option  value="Son">Son</option>
    <option  value="Daughter">Daughter</option>
    <option  value="Husband">Husband</option>
    <option  value="Grandfather">Grandfather</option>
    <option value=" Grandmother">Grandmother</option>
    <option value="Mother-in-law">Mother-in-law</option>
    <option value="Father-in-law 8">Father-in-law</option>
    </select></td>
    <td><input type="text" name="il"></td>
    <td><input type="text" name="sal"></td>
    <td><input type="text" name="lb" ></td>
    <td><input type="text" name="ll" ></td>
    <td><input type="text" name="rl" ></td>
    <td><input type="text" name="ai" ></td>
    <td><input type="text" name="tot" ></td>
    </tr>
    </tbody>
    </table>
    <table>
    <tr><td><input type="submit" name="submit"></td></tr>
    <tr><td>


            <input type="button" id="btnAdd" value="add another name" /></td><td>
            <input type="button" id="btnDel" value="remove name" /></td>
       </tr>
    </table>
</form>

配给数量和总数
Aadaar编号关系土地工资/养老金收入业务收入劳动力租金收入其他收入合计
主人
父亲
母亲
儿子
女儿
丈夫
祖父
祖母
岳母
岳父

您没有添加结束表单标记。我会添加该标记并将开始表单标记移到表外,但这只是我的首选

<form name="f10"  id="myform" method=POST action="http://testxml.net84.net/abel-test/test.php">
    <table id="myTable">
        .. table ..
    </table>
</form>

桌子
另外,您只为添加的脚本的
adno['+rows+']
部分添加了一个数组。因此,即使添加了表单标记,您也只能在打印的数组中获得额外的adno标记


为此,您应该将元素命名为数组的一部分,这样
name=relation
将变成
name=adno['+rows+'][relation]
。然后,每一行新元素将成为输出数组中的新行。

始终将所有相关代码和标记放在问题本身中。此外,当您键入问题时,有一个方便的方法可以将框格式化到右侧--值得一读!)@Abel Jojo还确保表单包含两个嵌套表,原始代码只包含表单中的第一个表。