jquery - PHP AJAX Change value based on combobox -
what want every time have change value combobox (value combobox database ) input type change too
here
<div class="col-md-12" > <label>charge</label> <select id="name" name="name" class="form-control"> <?php while ($reserve=mysqli_fetch_array($charge)) { ?> <option value=" <?php echo $reserve['name']?>"> <?php echo $reserve['name']; ?> </option><?php } ?> </select> </div> <div class="col-md-12"> <br> <label>price</label> <input type="number" class="form-control" id="price" name="price" disabled> </div>
on database name has corresonding price example chair has 200 price want every time changed combobox value @ inputtype change too
i not sure why use ajax if want show option value . please check code .
$('#name').change(function () { var option_value = $(this).val(); $('#price').val(option_value); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form> <select id="name" name="name"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <div class="col-md-12"> <br> <label>price</label> <input type="number" class="form-control" id="price" name="price" disabled> </div> </form>
so update select code using code
<select id="name" name="name" class="form-control"> <?php while ($reserve=mysqli_fetch_array($charge)) { ?> <option value=" <?php echo $reserve['name']?>"> <?php echo $reserve['name']; ?> </option><?php } ?> </select>
Comments
Post a Comment