答案 0 :(得分:1)
function ResetDefaultReportOptions() {
var report = document.getElementById('selectReport').value;
var policy = document.getElementById('selectPolicy');
if (report == 'All Reports' ||
report == 'Completed Reports') {
if(policy.options.item(1).value != 'All policies'){
o = document.createElement('option');
o.text = 'All policies';
o.value = 'All policies';
policy.options.add(o,1);
}
}
else{
if(policy.options.item(1).value == 'All policies'){
policy.options.remove(1);
}
}
}
document.getElementById('selectReport').onchange = function(){
ResetDefaultReportOptions();
}
select {
font-size: 1em;
padding: 4px;
border-radius: 3px;
}
<select name="selectReport" id="selectReport">
<option value="Make a Selection">Make a Selection</option>
<option value="All Reports">All Reports</option>
<option value="Completed Reports">Completed Reports</option>
<option value="Missing Reports">Missing Reports</option>
<option value="Closed Reports">Closed Reports</option>
</select>
<select name="selectPolicy" id="selectPolicy">
<option value="Make a Selection">Make a Selection</option>
<option value="0123456-001">0123456-001</option>
<option value="0123456-002">0123456-002</option>
<option value="0123456-003">0123456-003</option>
<option value="0123456-004">0123456-004</option>
<option value="0123456-005">0123456-005</option>
</select>