mardi 3 janvier 2017

Getting value from select dropdown with javascript

I'm creating a criteria with 3 rate selection. Now the problem when i'd tried to dd in my controller? The return is null. Anyone knows what is wrong in my java-script code? Sorry because i'm not so familiar with java-script.

$('select').on('change', function() {
                            selected = [];

                            $('select').each(function() {

                                if ($(this).val() !== "No Match")

                                    selected.push($(this).find('option:selected').val());

                            });
                            console.log(selected);

                            $('select').children().each(function(index) {

                                if ($.inArray($(this).val(), selected) !== -1) {
                                    $(this).attr('disabled', true);

                                } else {
                                    $(this).attr('disabled', false);
                                }
                            });
                        });
<script src="http://ift.tt/1oMJErh"></script>
<h4>Criteria</h4>
            <div class="col-md-12 well">
                <div class="col-lg-12 form-group">
                    <div class="col-lg-5">
                        <label class="control-label">
                            Age from:
                        </label>
                        <input type="text" name="ship_age_from" class="form-control">
                    </div>
                    <div class="col-lg-4">
                        <label class="control-label">
                            Age to:
                        </label>
                        <input type="text" name="ship_age_to" class="form-control">
                    </div>
                    <div class="col-lg-3">
                        <label class="control-label">
                            Rate:
                        </label>
                      <select name="ship_rate_one">
    <option>No Match</option>
    <option value="0">Choose</option>
    <option value="one">One</option>
    <option value="two">Two</option>
    <option value="three">Three</option>
</select>
                  </div>
                </div>
                <div class="col-lg-12 form-group">
                    <div class="col-lg-5">
                        <label class="control-label">
                            GPA from:
                        </label>
                        <input type="text" name="ship_gpa_from" class="form-control">
                    </div>
                    <div class="col-lg-4">
                        <label class="control-label">
                            GPA to:
                        </label>
                        <input type="text" name="ship_gpa_to" class="form-control">
                    </div>
                    <div class="col-lg-3">
                        <label class="control-label">
                            Rate:
                        </label>
                      <select name="ship_rate_two">
    <option>No Match</option>
    <option value="0">Choose</option>
    <option value="one">One</option>
    <option value="two">Two</option>
    <option value="three">Three</option>
</select>
                  </div>

                                      <div class="col-lg-3">
                        <label class="control-label">
                            School Level:
                        </label>
                      <select name="ship_level">
    <option>No Match</option>
    <option value="0">Choose</option>
    <option value="Primary">Primary</option>
    <option value="Secondary">Secondary</option>
    <option value="Tertiary">Tertiary</option>
</select>
                  </div>

                    <div class="col-lg-6 form-group">
                        <label class="control-label">
                            Rate:
                        </label>
                                       <select name="ship_rate_three">
    <option>No Match</option>
    <option value="0">Choose</option>
    <option value="one">One</option>
    <option value="two">Two</option>
    <option value="three">Three</option>
</select>

                    </div>
              </div>
              
</div>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire