下拉值不是实际插入的

时间:2017-01-22 14:36:40

标签: javascript html

如果我选择是,则插入查询在数据库中为11:

<td align="center">Offers in Hand :</td>
<td>
  <select name="Offers_in_Hand" id="Offers_in_Hand_Id" style="width: 250px" Required>
    <option selected></option>
    <option value="11">Yes</option>
    <option value="22">No</option>
  </select>
</td>

1 个答案:

答案 0 :(得分:0)

option s value更改为所需,在您的情况下为“是”&amp; “不”,像这样:

(仅添加jQuery以确认正在捕获正确的值)

$("#Offers_in_Hand_Id").change(function() {
  var value = $("#Offers_in_Hand_Id").val();
  $("#test").html(value);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td align="center">Offers in Hand :</td>
<td>
  <select name="Offers_in_Hand" id="Offers_in_Hand_Id" style="width: 250px" Required>
    <option selected></option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
  </select>
</td>
<span id="test"></span>