lundi 21 septembre 2015

using ajax to get the values from database on form submit laravel

I have a select list in my form like

 <form class="form-horizontal form-bordered" method="post" action="formaction">
  <div class="form-group">
    <label class="col-md-3 control-label" for="inputSuccess">Amount</label>
        <div class="col-md-6">
           <select class="form-control mb-md" name="amount" id="amount">
                    <option value="10"> 10</option>
                    <option value="20">20</option>
                    <option value="30">30</option>
                    <option value="40">40</option>
                    <option value="50">50</option>
            </select>
        </div>

      <div class="input-group mb-md">
           <button type="submit" class="btn btn-warning btn-sm">Submit</button>
      </div>
</form>

And I have a table in database that stores corresponding values to selected dropdown values like

id      value         conversion
1         10            0.2
2         20            0.32
3         30            0.43
4         40            0.77

and so on

Now, When I submit my form, I want to show the users in alert the corresponding value of the selected one. For example, If user selects 20 from the dropdown, then, on submitting the form, users is supposed to see the corresponding conversion of 20 i.e 0.32 in this case in alert. I know I have to implement ajax for this, I just don't understand how to implement it. Kindly guide me through this one.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire