我試圖在點擊按鈕時添加一個類型。在按鈕點擊時添加輸入類型
這裏是我的jQuery腳本:
$(function(){
$("#add").click(function(){
$("#inputboxes").append("<tr class='light'><td colspan='3' class='header'>Subject Name</td><td colspan='3'><input type='text' name='subject_name' /></td></tr>");
})
});
然後我的HTML標記:
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table cellpadding="0" cellspacing="0" style="text-align:center;">
<thead>
<tr>
<th colspan="7">Add subject on the list of available subjects</th>
</tr>
</thead>
<tbody id="inputboxes">
<tr class="dark">
<td colspan="7">
<input type="button" id="add" value="Click to add a subject" />
</td>
</tr>
</tbody>
<tbody>
<tr class="dark">
<td colspan="7"><input type="submit" name="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
#on page top
if(isset($_GET['submit']) print_r($_GET); // the only entry of array is the [submit'] => "Submit"
我可以成功地生成一個盒子,但它似乎每當我點擊提交,箱子不似乎通過了。另外我怎樣才能在生成的框的名稱=「」中生成一個增量。
爲了記錄,我找到了解決方法,將表格標籤移到了表格之外。感謝大家。
而問題是? – Cyclonecode
這不適合你嗎?你面臨的問題是什麼? –
我編輯了我的帖子,我無意中提交了這個問題,但沒有完成。 –