Welcome Guest, Not a member yet? Register   Sign In
SELECT FROM DATABASE CI 3
#1
Photo 

hello everyone, I am using CI 3 and want to do multiple insert forms, this form contains select input from the database, after we select it will display the stock of the item we selected, when we press the (+) blue button to add a row using javascript, we must fill the select input with the same item data from the previous select input, now what I want to ask, is it possible that the select data that has been used will not be in the display of other select options.

if you see from the example, row 1 I select apple, and in row 2 I don't want the apple item to be option selected in row 2.

[Image: select.jpg]

Here my view code : 
PHP Code:
<button type="button" class="btn btn-info tambah-form" disabled><class="fa fa-plus"></i></button>
                                            <button type="button" class="btn btn-warning del-elements" disabled><class="fa fa-minus"></i></button>
                                            <div class="row" style="margin-top:20px;">
                                                <div class="col-8">
                                                    <div class="form-group">
                                                        <div class="controls">
                                                            <label>Nama Resep</label>
                                                            <select class="form-control select2 product" name="id_liquid1" id="id_liquid1" onchange="cari(1)" required>
                                                                <option>-- Nama Resep --</option>
                                                                <?php
                                                                
foreach ($resep as $value) {
                                                                    echo "<option value='$value->id_liquid'>$value->nama_resep ($value->ukuran mL)</option>";
                                                                }
                                                                ?>
                                                            </select>
                                                        </div>
                                                    </div>
                                                </div> 

My function javascript :
PHP Code:
$(".tambah-form").on('click', function(){
                
                
var jumlahkolom = $('#jumlahkolom').val();
                if(jumlahkolom == 5){
                    $(".tambah-form").attr('disabled','disabled');
                }
                
                row 
'<div class="rec-element'+i+'">'+
                        '<div class="row">'+
                            '<div class="col-8">'+
                                '<div class="form-group">'+
                                    '<div class="controls">'+
                                        '<label>Nama Resep</label>'+
                                        '<select class="form-control select2 product" name="id_liquid'+i+'" id="id_liquid'+i+'" onchange="cari('+i+')"  required>'+
                                            '<option>-- Nama Resep --</option>'+
                                            <?php foreach ($resep as $value) { ?>
                                                '<option value="<?php echo $value->id_liquid;?>"><?php echo $value->nama_resep." (".$value->ukuran." mL)";?></option>;'+
                                            <?php ?>
                                        '</select>'+
                                    '</div>'+
                                '</div>'+
                            '</div>'+ 
Reply


Messages In This Thread
SELECT FROM DATABASE CI 3 - by rudibudi2491 - 02-26-2025, 05:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB