<label><input type="checkbox" name="selection" value="wifi" checked onclick="filterLog(this)">wifi</label><br>
<select id="wifi" class="dropdownList" multiple size=3 onchange="filterLogSel()">
function filterLogSel() {
/* not fired by checkbox */
if (!checkMark) {
var breakCheck;
/* remove all the content */
var htmlSelectAdd = document.getElementById('logListBox');
for(var i=0, n=htmlSelectAdd.length; i<n; i++) {
htmlSelectAdd.options[i].remove();
n--;
i--;
}
/* add content according to the select value */
selecttags = document.getElementsByClassName('dropdownList');
for (key in jsonobj)
for(var i=0, n=selecttags.length; i<n; i++) {
for(var j=0, m=selecttags[i].length; j<m; j++) {
if (selecttags[i].options[j].selected) {
var re=new RegExp(selecttags[i].options[j].value);
if ((re.exec(jsonobj[key]))!=null) {
selectBoxOption = document.createElement("option");
selectBoxOption.value = key;
selectBoxOption.text = jsonobj[key];
htmlSelectAdd.add(selectBoxOption,null);
breakCheck = true;
break;
}
}
}
if (breakCheck) {
breakCheck = false;
break;
}
}
}
}
当我在 chrome 中调试它时,我发现当我单击选择标签中的选项时,它会触发复选框的 onclick 函数而不是 select 的 onchange 函数。我希望触发选择的 onchange 函数。