0

I have created one IMS System. In that i have to create bill on order page and in order page when i select customer name from drop down than customer_address,customer_phone and gst number should automatically fill in text box.In database i have created one table named partys in that all data are available(Customer_name,Customer_address,customer_phone and gst) If anybody knows solution than please help. Below is my code

            <?php
              $dbc = mysqli_connect('localhost', 'root', '', 'stock')
                or die('Error connecting to MySQL server.');
              $query = "SELECT * FROM partys";
              $result = mysqli_query($dbc, $query);
              while ($row = mysqli_fetch_array($result)) {
            ?>
              <option value="<?php echo $row['party_name'] ?>"><?php echo $row['party_name'] ?></option>
            <?php } ?>
            </select>
            </div>
          </div>

          <div class="form-group">
            <label for="gross_amount" class="col-sm-5 control-label" style="text-align:left;">Customer Address</label>
            <div class="col-sm-7">
              <input type="text" class="form-control" id="customer_address" name="customer_address" placeholder="Enter Customer Address" autocomplete="off">
            </div>
          </div>

          <div class="form-group">
            <label for="gross_amount" class="col-sm-5 control-label" style="text-align:left;">Customer Phone</label>
            <div class="col-sm-7">
              <input type="text" class="form-control" id="customer_phone" name="customer_phone" placeholder="Enter Customer Phone" autocomplete="off">
            </div>
          </div>

          <div class="form-group">
            <label for="gstin" class="col-sm-5 control-label" style="text-align:left;">GSTIN</label>
            <div class="col-sm-7">
              <input type="text" class="form-control" id="gstin" name="gstin" placeholder="Enter GST Number" autocomplete="off">
            </div>
          </div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        // On change of the dropdown do the ajax
        $("#client").change(function() {
            $.ajax({
                    // Change the link to the file you are using
                    url: '/create.php',
                    type: 'post',
                    // This just sends the value of the dropdown
                     data: {customer_name : party_name},
                     dataType: 'json',
                    success: function(response) {
                        // Parse the jSON that is returned
                        // Using conditions here would probably apply
                        // incase nothing is returned
                        var Vals    =   JSON.parse(response);
                        // These are the inputs that will populate
                        $("#customer_address").val(response.customer_address);
                        $("#customer_phone").val(response.customer_phone);
                        $("#gstin").val(response.gstin);
                    }
            });
        });
    });
</script>

0 Answers0