我希望能够从两个不同的下拉列表中选择多个值,并使用输出值调用单独的函数。我可以独立获取每个值,但希望能够有一个同时获取这两个值的函数
<!DOCTYPE html>
<html>
<body>
<select id ="cars1">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<select id ="cars2">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<script>
//select the value from the dropdown table with id ="cars1"
var selectCars1 = document.getElementById("cars1");
selectCars1.onchange = function start(){
var Cars1Value = selectCars1.options[selectCars1.selectedIndex].value;
alert(Cars1Value);
}
//select the value from the dropdown table with id ="cars2"
var selectCars2 = document.getElementById("cars2");
selectCars2.onchange = function(){
var Cars2Value = selectCars2.options[selectCars2.selectedIndex].value;
alert(Cars2Value);
}
</script>
</body>
</html>