如何在此列表中添加选择按钮?

时间:2016-02-08 09:54:43

标签: html select

如何从自动更改为下拉字段中的网址的下拉列表中将此列表更改为用户必须选择绿色“选择”按钮的下拉列表?

谢谢你, 史蒂夫。

<select name="cars" id="dynamic_select">
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Borrowing-Power-Calculator.aspx?ID=MFAA">Borrowing Power Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Loan-Repayment-Calculator.aspx?ID=MFAA">Loan Repayment Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Lump-Sum-Repayment-Calculator.aspx?ID=MFAA">Lump Sum Repayment Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Extra_Repayment_Calculator.aspx?ID=MFAA">Extra Repayment Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Budget-Planner.aspx?ID=MFAA">Budget Planner</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Loan-Comparison-Calculator.aspx?ID=MFAA">Loan Comparison Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/How-Long-to-Repay-Calculator.aspx?ID=MFAA">How Long to Repay Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Split-Loan-Calculator.aspx?ID=MFAA">Split Loan Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Property-Selling-Cost-Calculator.aspx?ID=MFAA">Property Selling Cost Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Property-Buying-Cost-Calculator.aspx?ID=MFAA">Property Buying Cost Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Saving-Calculator.aspx?ID=MFAA">Saving Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Term-Deposit-Calculator.aspx?ID=MFAA">Term Deposit Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Stamp-Duty-Calculator.aspx?ID=MFAA">Stamp Duty Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Credit-Card-Calculator.aspx?ID=MFAA">Credit Card Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Income-Tax-Calculator.aspx?ID=MFAA">Income Tax Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Reverse-Mortgage-Calculator.aspx?ID=MFAA">Reverse Mortgage Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Leasing-Calculator.aspx?ID=MFAA">Leasing Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Home-Loan-Offset-Calculator.aspx?ID=MFAA">Home Loan Offset Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Honeymoon-Loan-Calculator.aspx?ID=MFAA">Honeymoon Loan Calculator</option>
  <option value="http://www.visionabacus.com/Finance/Australia/1/SuiteA100/640/Comparison-Rate-Calculator.aspx?ID=MFAA">Comparison Rate Calculator</option>
</select>

<script>
    $(function(){
      // bind change event to select
      $('#dynamic_select').on('change', function () {
          var url = $(this).val(); // get selected value
          if (url) { // require a URL
              window.location = url; // redirect
          }
          return false;
      });
    });
</script>

1 个答案:

答案 0 :(得分:0)

检查一下:

<select name="cars" id="dynamic_select">
  <option value="https://google.com">google.com</option>
  <option value="https://google.de">google.de</option>
</select>

<强> JS:

  $('#dynamic_select').on('change', function () {
      var url = $(this).val();
        window.location = url; 
  });

<强>更新

&#13;
&#13;
 $('#Submit').on('click', function () {
      var url = $('#dynamic_select').val();
        window.location = url;
        alert(url); // remove this line later
  });
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select name="cars" id="dynamic_select">
  <option value="https://google.com">google.com</option>
  <option value="https://google.de">google.de</option>
</select>
<input id="Submit" value="Go" type="submit"/>
&#13;
&#13;
&#13;