如果#cities选项值与#cities2数据属性值匹配,我想显示#cities2中的选项。
例如,如果首先选择迈阿密,那么在第二选择框中仅显示迈阿密,并从#cities2中删除或禁用所有其他选项。
这是我正在尝试的代码:
<select name="cities" id="cities">
<option value="Los Angeles">Los Angeles</option>
<option value="Miami">Miami</option>
<option value="Las Vegas">Las Vegas</option>
<option value="Chicago">Chicago</option>
</select>
<select name="cities2" id="cities2">
<option data-cities="Los Angeles">Los Angeles</option>
<option data-cities="Miami">Miami</option>
<option data-cities="Las Vegas">Las Vegas</option>
<option data-cities="Chicago">Chicago</option>
</select>
<script>
$('#cities').change(function(e){
var $option = $('#cities2 option').data('cities');
if($(this).val() == "Miami" && $option == "Miami" ){
$("#cities2 option").prop('disabled',true);
$("#cities2 option[data-cities='Miami']").prop('disabled',false);
}else {
$("#cities2 option").prop('disabled',false);
};
});
</script>
在此先感谢您的帮助。
答案 0 :(得分:1)
答案 1 :(得分:0)
WITH salaries AS (
SELECT category,
salary
NTILE(10) OVER (PARTITION BY category ORDER BY SALARY asc) AS decile
FROM employees
)
SELECT category,
SUM(salary) FILTER (WHERE decile = 1) /
SUM(salary) FILTER (WHERE decile = 10) AS ratio
FROM salaries
GROUP BY category
您在JavaScript开头出现错误。这是可行的解决方案(例如您的示例也不是通用的)