0

我有以下 Javascript 函数:

function showRSS(str, year, month, day) {
    if (str.length == 0) {
        document.getElementById("rssOutput").innerHTML = "";
        return;
    }
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById("rssOutput").innerHTML = xmlhttp.responseText;
        }
    }

    xmlhttp.open("GET", "domain.com/script.php?days=" + str + "&year=" + year + "&month=" + month + "&day=" + day, true);

    xmlhttp.send();
}

以及以下选择字段(下拉菜单),但是当其中的值发生更改时,不会触发该功能:

<div id="calendar-container">

<input type="text" onchange="checkAge( this );" onkeypress="return isNumberKey(event)" alt="Test" value="" onkeyup="showRSS(this.value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, document.getElementById('daySel').value)" name="nights" id="field2">

    <select id="monthSel" name="monthSel"
    onchange="showRSS(document.getElementById('field2').value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, document.getElementById('daySel').value)">
        <option value="0">January</option>
        <option value="1">February</option>
        <option value="2">March</option>
        <option value="3">April</option>
    </select>
    <select id="daySel" name="daySel" 
    onchange="showRSS(document.getElementById('field2').value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, document.getElementById('daySel').value)">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
    </select>
</div>

任何人都知道为什么没有触发该功能的解决方案?

4

0 回答 0