嗨,我有一个表单,当用户单击添加按钮时,它会动态生成一个表行表格行它不附加任何表格行我尝试在控制台中检查我的数据。正在传输数据但不附加我的代码有什么问题吗?提前谢谢这里是我的脚本
$(document).ready(function(){
$('#addnew').click(function(){
var ctr = $('#items').val();
ctr++;
$.post('purch_srch.php', {ctr : ctr}, function(data) {
$(data).appendTo('#detail');
$('#items').val(ctr);
});
});
});
这是我的 php
<?php
session_start();
require("includes/dbconnect.php");
include ('includes/function.php');
$zdb = $_SESSION["zdbyear"];
mysql_select_db($zdb);
if ($_REQUEST["ctr"]){
$ctr = $_REQUEST["ctr"];
echo '<tr>';
echo '<td align="center"><input type="text" size="6" maxlength="6" maxlength="6" name="ord_'.$ctr.'" class="form-input-oth"/></td>';
echo "<td align='center'>";
echo '<select data-placeholder="Party" style="width:120px;" name="item_'.$ctr.'" class="chzn-select-deselect" >';
echo "<option value = '' ></option>";
$get = mysql_query("SELECT * FROM accmast WHERE `grpcode`='010'") or die(mysql_error());
while($cc = mysql_fetch_array($get)){
echo "<option value='.$cc[accode].'/>$cc[name]</option>";
}echo"</select>";
echo "</td>";
echo "</select></td>";
echo '<td align="center"><input type="text" size="6" maxlength="9" maxlength="6" name="descrip_'.$ctr.'" class="form-input-name"/></td>';
echo '<td align="center"><input type="text" size="6" maxlength="9" maxlength="6" name="unit_'.$ctr.'" class="form-input-rate"/></td>';
echo '<td align="center"><input type="text" size="6" maxlength="9" maxlength="6" name="totqty_'.$ctr.'" class="qty form-input-rate"/></td>';
echo '<td align="center"><input type="text" size="6" maxlength="9" maxlength="6" name="rate_'.$ctr.'" class="rate form-input-rate"/></td>';
echo '<td align="center"><input type="text" size="6" maxlength="9" maxlength="6" name="amt_'.$ctr.'" class="cal form-input-amt"/></td>';
echo "</tr>";
exit();
}
else{
echo "ERROR";
}
这是我的桌子
<table id="detail" border="1px" width="90%">
</table>
<input type="button" id="addnew" class="classname" name="addnew" value="+" />
<input type="text" id="items" name="items" value="0" />