簡體   English   中英

發布由Jquery添加到表單的html元素

[英]Post html elements added by Jquery to form

我有一個表和2個按鈕來添加和刪除一組通過Jquery動態添加的html元素。 當我提交表格時。 操作頁面僅打印僅手動編碼的表單元素。

我用$('#myTable tr:last')完成了這個。之后(newElem);

在jQuery中。

這里是鏈接www.jsfiddle.net/abelkbil/3GbWH/3/

這就是出局

數組([rno] => 123 [adno] =>數組([0] => 1235 它不打印 [1] => x) [rel ....

感謝所有的支持

form標記未在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>

您尚未添加結束表單標記。 我會添加它並將開始表單標記移動到表外,但這只是我的偏好。

<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] 然后,每行新元素將成為輸出數組中的新行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM