大家好我试图在表单中附加表格。但是我在控制台中有一条错误消息:"Uncaught SyntaxError: missing ) after argument list"
。当我单击按钮添加行时,它会一直指向我的PHP脚本。我试图解决这个问题,但无论如何对不起英语不好,这就是代码。
$('#more_row').append('<tr id="row'+i+'"><td><?php echo "<select name='alpha_num[]' class='form-control' id='item'>"; echo"<option value=''selected disabled>Select Material</option>";while($row = mysqli_fetch_row($result1)){echo"<option value=$row[0]>$row[1]$row[0]</option>";}echo"</select>";?></td><td><input type="text" name="qty[]" class="form-control" id="quantity" placeholder="Qty"></td><td><input type="text" name="uom[]" class="form-control" id="um" placeholder="UOM"></td><td><select name="status[]" class="form-control" id="stat"><option value="approved">approved</option><option value="return">return</option></select></td><td><button id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
});
&#13;
<div class="panel-body">
<form method="post" action="material_receive_report_process.php">
<div class="row">
<div class="col">
<label for="dr">PO.NO</label>
<input type="text" name="dr_no" class="form-control" id="dr">
</div>
<div class="col">
<label for="dr">DR.NO</label>
<input type="text" name="dr_no" class="form-control" id="dr">
</div>
<div class="col">
<label for="date">Date</label>
<input type="text" name="date" class="form-control" id="date">
</div>
</div>
<table id="more_row">
<tr>
<td>
<?php echo "<select name='alpha_num[]' class='form-control' id='item'>";
echo"<option value=''selected disabled>Select Material</option>";
while($row = mysqli_fetch_row($result1)){
echo"<option value=$row[0]>$row[1]$row[0]</option>";
}
echo"</select>";
?>
</td>
<td>
<input type="text" name="qty[]" class="form-control" id="quantity" placeholder="Qty">
</td>
<td>
<input type="text" name="uom[]" class="form-control" id="um" placeholder="UOM">
</td>
<td>
<select name="status[]" class="form-control" id="stat">
<option value="approved">approved</option>
<option value="return">return</option>
</select>
</td>
<td><button id="add1" class="btn btn-info">Add</button></td>
</tr>
</table>
<br>
<p>Condition:
<input type="checkbox" name="condition[]" value="damage_visible">Damage visible
<input type="checkbox" name="condition[]" value="good_condition">Good conditon
<input type="checkbox" name="condition[]" value="full_qty">Full qty
<input type="checkbox" name="condition[]" value="partial_qty">Partial qty</p>
<div class="form-group">
<label for="supp">Supplier</label>
<input type="text" name="supplier" class="form-control" id="supp">
</div>
<div class="form-group">
<label for="remark">Remarks</label>
<textarea name="remark" class="form-control" id="remark"></textarea></p>
<input type="submit" name="save" class="btn btn-success" value="Save">
</div>
</form>
<br><br>
</div>
</div>
&#13;
答案 0 :(得分:0)
&#39;添加行&#39;按钮提交表单,因为the default value for the type
attribute of button
elements is "submit"。我的猜测是语法错误是由于PHP在Javascript中转储的单引号,双引号和换行符的混乱。查看浏览器生成的代码。这是需要正确形成的东西。
答案 1 :(得分:0)
错误很可能是由于Php和JavaScript字符串之间的冲突造成的。考虑转义ie'和使用不同的两个说JavaScript使用双引号“而Php使用单引号'