I am newbie in php as well as bootstrap. I am trying to create master-detail form to receive product from supplier. I had somehow manage to build the format but have difficulties on cloning table row with php select box. My HTML codes are below ...
<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>
Please anyone can solve my issue will be greatfull. I need to dynamically Add and Remove Row with this two buttons. Also if anyone have any reference on how to make master-detail form in php with bootstrap will support me well. Thank you in Advance.
To get a concept please check the following URL. I want to add Parts Name to Total as a new row when I press + Add More. Please note that the Parts Name comes from MySQL through PHP code ...
jsfiddle.net/imranctgbd/34djbLLn