-1

不是一个复杂的,但我的编码知识非常有限。

IM正在寻找从选择菜单(少于$ 10,000)的值时要显示的消息,并且还可以防止表格提交。

<select name="levelofdebt" class="form-control" id="levelofdebt" required>
                                      <option value="" disabled selected="selected">Select total debt</option>
                                      <option value="$10,000 or less">Less than $10,000</option>
                                      <option value="$10-15k">$10,000 - $15,000</option>
                                      <option value="$15-20k">$15,000 - $20,000</option>
                                      <option value="$20-30k">$20,000 - $30,000</option>
                                      <option value="$30-40k">$30,000 - $40,000</option>
                                      <option value="$40-50k">$40,000 - $50,000</option>
                                      <option value="$50-60k">$50,000 - $60,000</option>
                                      <option value="$60-100k">$60,000 - $100,000</option>
                                      <option value="$100k +">$100,000 +</option>
                                    </select>

提前致谢

4

1 回答 1

0

function selectchange(){
  if($("#levelofdebt").val() == '$10,000 or less')
    {
        
        alert('Amount Less than $10,000');
      return false; // prevents page reload
    }
  else{
     // Do something
  }

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="levelofdebt" class="form-control" id="levelofdebt" required onchange="return selectchange();">
                                      <option value="" disabled selected="selected">Select total debt</option>
                                      <option value="$10,000 or less">Less than $10,000</option>
                                      <option value="$10-15k">$10,000 - $15,000</option>
                                      <option value="$15-20k">$15,000 - $20,000</option>
                                      <option value="$20-30k">$20,000 - $30,000</option>
                                      <option value="$30-40k">$30,000 - $40,000</option>
                                      <option value="$40-50k">$40,000 - $50,000</option>
                                      <option value="$50-60k">$50,000 - $60,000</option>
                                      <option value="$60-100k">$60,000 - $100,000</option>
                                      <option value="$100k +">$100,000 +</option>
                                    </select>

于 2015-07-01T16:20:04.780 回答