lundi 28 octobre 2019

Can i submit form and selected checkbox?

I have a purchase order page in that page i have form like below

<form action="" method="post">
                <div class="container">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Tanggal PO</label>
                                <input class="form-control" type="text" name="tanggal_po" id="datepicker">
                                {!! $errors->first('tanggal_po','<span class="text-danger">:message</span>') !!}                                                                                        
                            </div>

                            <div class="form-group">
                                <label>No Po</label>
                                <input class="form-control" type="text" name="no_po">
                                {!! $errors->first('no_po','<span class="text-danger">:message</span>') !!}                                                            
                            </div>

                            <div class="form-group">
                                <label>Supplier</label>
                                <select name="supplier_nama" class="form-control">
                                    <option value=""hidden>Pilih Supplier</option>
                                    @foreach ($supplier as $s)
                                        <option value=""></option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Apoteker</label>
                                <select name="apoteker_nama" class="form-control">
                                    <option value=""hidden>Pilih Apoteker</option>
                                    @foreach ($apoteker as $a)
                                        <option value=""></option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="form-group">
                                <label>Keterangan</label>
                                <input class="form-control" type="text" name="keterangan">
                            </div>
                        </div>
                    </div>
                </div>

                <button type="submit" class="btn btn-success simpan"><i class="fas fa-check"> Simpan</i></button>

and i also have a table

 <table class="table table-bordered" style="margin-top:20px">
             <tbody>
                 <tr class="text-center">
                     <th>No</th>
                     <td>Kode Obat</td>
                     <td>Nama Obat</td>
                     <td>Harga Obat</td>
                     <td>Jumlah Obat PO</td>
                     <td>Harga Obat PO</td>
                 </tr>
                 @foreach ($obat as $o)
                 <tr>
                            <td class="text-center">
                                    <input id="" type="checkbox" name="select">
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="" class="form-control" type="text" name="kode_obat" value="" readonly>                                        
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="" class="form-control" type="text" name="nama_obat" value="" readonly>
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="harga" class="form-control" type="text" onkeyup="sum()" value="" readonly>
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="jumlah" class="form-control" onkeyup="sum()" type="text" name="jumlah">
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="total" class="form-control" type="text" onkeyup="sum()" name="harga_obat" readonly>
                                </div>
                            </td>

                        
                    </tr>
                    @endforeach
             </tbody>
         </table>

in that table there is a checkbox name select, i want when i input the form and select the checkbox i can click on the submit button, both the form and checkbox can be insert into database.

the checkbox name="select" is from purchase_order table. this is my migration table

$table->increments('id');
$table->date('tanggal_po');
$table->string('select');
$table->string('no_po');
$table->string('supplier_nama');
$table->string('apoteker_nama');
$table->string('kode_obat');
$table->string('nama_obat');
$table->integer('jumlah')->unsigned()->nullable();
$table->string('harga_obat');
$table->string('keterangan');



Aucun commentaire:

Enregistrer un commentaire