2 回答

TA貢獻(xiàn)1858條經(jīng)驗 獲得超8個贊
查看發(fā)票表格頁面:-
<div class="row space">
<label class="control-label">Customer Name<span class="manda">*</span></label>
<select class="form-control" name="customerId" id="customerId">
<option value="0">Choose Customer Name</option>
<?php
if ($customer) {
foreach ($customer as $row) {
echo "<option value='".$row->customerId."'>".$row->customer_name."</option>";
}
}
?>
</select>
</div>
<div class="row space">
<div class="col-sm-6">
<div id='billData'></div>
</div>
</div>
Jquery Ajax 代碼:-在關(guān)閉標(biāo)簽之前在發(fā)票表單視圖頁面中添加此代碼</body>。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#customerId").on("change",function(){
var customerId = $(this).val();
$.ajax({
url : "<?php echo base_url('controler_Name/get_data_in_bill_checkbox') ?>",
type: "post",
data: {"customerId":customerId},
success : function(data){
//alert(data);
$("#billData").html(data);
}
});
});
});
</script>
控制器代碼:-
public function get_data_in_bill_checkbox(){
$customerId = $this->input->post("customerId");
$BillTableDta = $this->db->get_where('bill_address',array('customerId'=>$customerId))->row_array();
$billData = "<label>Bill To</label>";
foreach($BillTableDta as $bill)
{
$billData.='<input type="checkbox" name="billcheckbox" value="'.$bill.'">';
}
echo $billData;
}
注意:-有關(guān)更多參考,請參閱此https://api.jquery.com/change/

TA貢獻(xiàn)1876條經(jīng)驗 獲得超7個贊
您可以使用以下命令讓我知道使用三角形是否有效。:-)
<div class="row space">
<form action="" method="POST">
<label class="control-label">Customer <span class="manda">*</span></label>
<select class="form-control" name="customerId" onchange="this.form.submit()" id="customerId">
<option value="0">Choose....</option>
<?php
if ($customer) {
foreach ($customer as $row) {
echo "<option value='".$row->customerId.'/'.$row->customer_name."'>".$row->customer_name."</option>";
}
}
?>
</select>
<?php
if(isset($_POST['customerID'])){
$true=checked;
$data=explode("/",$_POST['customerID']);
$id=$data[0];
$name=$data[1];
}
else {
$true="";
}
?>
</div>
<div class="row space">
<div class="col-sm-6">
<input type="checkbox" <?php if(isset($true){ echo $true; } ?> name="checkbox" value="<?php if(isset($id){ echo $id; } ?>"> <!-- you can change this $id to $name based on your need.-->
<label><?php if(isset($name) { echo $name; } ?></label>
</div>
</div>
</form>
- 2 回答
- 0 關(guān)注
- 126 瀏覽
添加回答
舉報