【发布时间】:2015-12-17 02:41:42
【问题描述】:
我是 php 和 bootstrap 的新手。我正在尝试创建主详细信息表单以从供应商处接收产品。我以某种方式设法构建了格式,但在使用 php 选择框克隆表行时遇到了困难。我的 HTML 代码如下...
<div class="form-group">
<div class='row'>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
<div class='col-xs-10 col-sm-10 col-md-10 col-lg-10'>
<table class="table table-bordered table-hover" id="table-data">
<thead>
<tr>
<th width="2%"><input id="check_all" class="formcontrol" type="checkbox"/></th>
<th width="38%">Parts Name</th>
<th width="15%">Price</th>
<th width="15%">Quantity</th>
<th width="15%">Total</th>
</tr>
</thead>
<tbody>
<tr id="id1" class="tr_clone">
<td><input class="case" type="checkbox"/></td>
<td>
<div class="dropdown">
<select data-type="partsCode" name="partsNo[]" id="partsNo1" class="form-control">
<?php
$query = "SELECT PARTS_ID, PARTS_NAME FROM parts_info ORDER BY PARTS_NAME";
if ($result = mysqli_query($con, $query))
{
while ($row = mysqli_fetch_array($result))
{
?>
<option value=<?php echo $row['PARTS_ID']; if ($shopid == $row['PARTS_ID']) echo " selected"; ?>> <?php echo $row['PARTS_NAME']; ?> </option>
<?php
}
}
mysqli_free_result($result);
?>
</select>
</div>
</td>
<td><input type="number" name="price[]" id="price1" class="form-control changesNo" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="quantity[]" id="quantity1" class="form-control changesNo" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
<td><input type="number" name="total[]" id="total1" class="form-control totalLinePrice" onkeypress="return IsNumeric(event);" ondrop="return false;" onpaste="return false;"></td>
</tr>
</tbody>
</table>
</div>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
</div>
<div class='row'>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
<div class='col-xs-12 col-sm-3 col-md-3 col-lg-3'>
<button class="btn btn-danger" type="button">- Delete</button>
<button class="btn btn-success" type="button">+ Add More</button>
</div>
<div class='col-md-3 col-md-offset-4'>
<button class="btn btn-primary btn-block" id="button" type="submit" name="submit" value="Submit">Save</button>
</div>
<div class='col-xs-1 col-sm-1 col-md-1 col-lg-1'> </div>
</div>
</div>
请任何人都可以解决我的问题。我需要使用这两个按钮动态添加和删除行。 此外,如果有人对如何使用引导程序在 php 中制作主从表单有任何参考,我会很好地支持我。提前谢谢你。
要了解概念,请查看以下 URL。当我按 + 添加更多时,我想将零件名称添加到总计中作为新行。请注意,零件名称通过 PHP 代码来自 MySQL ...
jsfiddle.net/imranctgbd/34djbLLn
【问题讨论】:
-
你了解MVC吗?
-
对不起,不。无论如何,谢谢你问...
-
要了解概念,请查看以下 URL。当我按 + 添加更多时,我想将零件名称添加到总计中作为新行。请注意,零件名称通过 PHP 代码来自 MySQL ...jsfiddle.net/imranctgbd/34djbLLn
标签: php jquery mysql twitter-bootstrap