我正在我的网站上工作并挂断了代码 请查看以下链接,了解我想说的内容 http://matchpoint.finetiger.com/classes-programs/
Shell RD - 健身与训练: - example.com Mill Basin - 健身与训练: - example2.com
<div id="classes-programs-page" class="classes-programs-page text-center">
<form class="form-inline" role="form">
<div class="form-group find-area">
<select id="clubs" class="form-control">
<option value="1">Shell Rd</option>
<option value="2">Mill Basin</option>
</select>
<i class="fa fa-chevron-down"></i>
</div>
<div class="form-group find-area">
<select id="programs" class="form-control">
<option value="3">Fitness & Training </option>
<option value="4">Aquatics </option>
<option value="5">Tennis</option>
<option value="6">Kids Programs</option>
</select>
<i class="fa fa-chevron-down"></i>
</div>
<button type="submit" class="btn btn-find">Find</button>
</form>
</div>
答案 0 :(得分:0)
试试这个:
$(document).ready(function() {
$('.btn-find').on('click', check_and_redirect);
function check_and_redirect() {
var urls = ["https://stackoverflow.com/", "https://www.google.com/", "https://www.yahoo.com/", "https://www.bing.com/", "https://www.wpchandra.com/", "https://www.codexbuddy.com/", "https://www.bbc.com/", "https://nasa.org/"];
if(($('#programs option:selected').val() != "") && ($("#clubs option:selected").val() != "")){
if (($("#programs option:selected").length > 0) && ($("#clubs option:selected").length > 0)) {
var index = parseInt(($('#clubs')[0].selectedIndex) * ($('#programs')[0].selectedIndex))-1;
window.location = urls[index];
}
else{
alert("Please choose programs and clubs!");
}
}
else{
alert("Please choose programs and clubs!");
}
return false;
}
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="clubs" class="form-control">
<option value="">--Select--</option>
<option value="1">Shell Rd</option>
<option value="2">Mill Basin</option>
</select>
<select id="programs" class="form-control">
<option value="">--Select--</option>
<option value="3">Fitness & Training </option>
<option value="4">Aquatics </option>
<option value="5">Tennis</option>
<option value="6">Kids Programs</option>
</select>
<button type="submit" class="btn btn-find">Find</button>
&#13;