第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Codeigniter:從下拉列表中選擇一個值時更改復(fù)選框的值

Codeigniter:從下拉列表中選擇一個值時更改復(fù)選框的值

PHP
炎炎設(shè)計 2023-09-22 14:50:55
我有 3 張桌子說:-發(fā)票詳細(xì)信息、客戶詳細(xì)信息和帳單地址。發(fā)票表格有adropdown和 a checkbox。Customer names列在下拉列表中customer table。當(dāng)我選擇一個customer name復(fù)選框值時,必須具有相應(yīng)的billId.因此,當(dāng)我標(biāo)記復(fù)選框時,復(fù)選框的值必須是billId已選擇的客戶名稱。我希望我的問題很清楚。查看頁面:-<div class="row space"> <label class="control-label">Customer <span class="manda">*</span></label> <select class="form-control" name="customerId" id="customerId">   <option value="0">Choose....</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">  <input type="checkbox" name="checkbox" value="bill">  <label>Bill To</label> </div></div>我怎么能這樣做呢?請幫我...customerId是普遍存在的3 tables。表格詳細(xì)信息:-bill_address(billId, customerId, street, city, state, country).customer_details(customerId, customer_name, phone, email,..).invoice_details(invoiceId, customerId, billId, date, status,..).
查看完整描述

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/


查看完整回答
反對 回復(fù) 2023-09-22
?
幕布斯6054654

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>


查看完整回答
反對 回復(fù) 2023-09-22
  • 2 回答
  • 0 關(guān)注
  • 126 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號