从选择下拉列表中获取价值

时间:2017-01-03 13:58:32

标签: javascript html laravel-5

我创建了3种速率选择的标准。现在问题是我试图在我的控制器中使用dd?返回值为null

任何人都知道我的JavaScript代码有什么问题?抱歉,因为我对JavaScript不熟悉。



$('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="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/css/tether.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet"/>

<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>
&#13;
&#13;
&#13;

0 个答案:

没有答案