lundi 2 novembre 2015

How can I pass a jquery value from a selected dropdown list to a variable in laravel 5.1?

I have created field for (price) in the controller class like so. protected $fields = [ 'tag' => '', 'title' => '', 'location' => '', 'property_type' => '', 'residence_name' => '', 'bedroom_no' => '', 'price' => '', 'lease' => 0, ]; I have also created a column (price) in my table for migration like so. Schema::table('tags', function (Blueprint $table) {

        $table->string('location');
        $table->string('property_type');
        $table->string('residence_name');
        $table->string('bedroom_no');
        $table->string('price');
        $table->boolean('lease');

    });

other fields are saved in the database because they are text input fields. Here is a working sample code for location input field being saved in the database Location / City and here is the code for price dropdown, i want get the value of var price from jquery and then pass it to the $price var in php laravel

 <div class="form-group">
  <label for="price" class="col-md-3 control-label">
   Price
  </label>
  <div class="col-md-4">
   <select class="form-control" id="price" value="{{ $price }}">
    <option>10,000 - 15,000</option>
    <option>15,000 - 20,000</option>
    <option>20,000 - 25,000</option>
    <option>30,000 - 50,000</option>
    <option>50,000 and Above</option>
   </select>
  </div>
 </div>

with a jquery script code to accept the input from user $("#price").change(function () { var price = $(this).val(); alert(price); });

Please help me out. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire