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