Skip to content
Advertisement

when i enter Price 0 the status need show outstock in CodeIgniter

View Code when I enter Price 0 the status need show out stock in CodeIgniter
i.e if I enter 0 prices in amount felid automatically in status felid its need to show outofstock if enter above 0 its need to show instock

<div class="col-md-6">
<div class="input-group mb-3">
<div class="input-group-prepend">
                                            <span class="input-group-text">Price</span>
                                        </div>
<input type="text" required class="form-control" name="product_price" aria-label="Amount (to the nearest dollar)">
                                        <div class="input-group-append">
                                            <span class="input-group-text">AED</span>
                                        </div>


  <div class="col-md-6">
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <label class="input-group-text" for="inputGroupSelect01">Status</label>
                                        </div>
                                        <select class="custom-select" name="product_status" id="inputGroupSelect01">
                                            <option value="In Stock">In Stock</option>
                                            <option value="Out of Stock">Out of Stock</option>
                                        </select>
                                    </div>
                                </div>

Advertisement

Answer

For More Info Regarding keyup() :-

https://api.jquery.com/keyup/

$(document).ready(function() {
  $('#otherCategory').keyup(function() {
    if ($(this).val() == 0) {
      $('#category').val(0);
    } else if ($(this).val() > 0) {
      $('#category').val(1);
    } 
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="text" id="otherCategory" name="otherCategory">

<select id="category" name="category">
  <option value="">Please select</option>
  <option value="0">Out Of STock</option>
  <option value="1">In STock</option>
</select>
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement