onchange不能使用?

时间:2012-02-10 08:48:11

标签: javascript ajax onchange

function gettime(str) {

        var strURL="/Doctor/booking/gettime.jsp?datepicker="+str;
        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {
                        document.getElementById('d11').innerHTML=req.responseText;
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }
            }
            req.open("GET", strURL, true);
            req.send(null);
        }
    }
<b>Date:<input id="d11" type="text" name="datepicker" onClick="WdatePicker()" onchange="gettime(this.value)"/></b>

当我单击文本框,提醒日期选择器并选择日期时,文本框应更改其值。但事实并非如此。我可以用什么方法解决它?

此外,当我直接输入此URL:/Doctor/booking/gettime.jsp?datepicker=2012-02-02时,我看到了我想要的输出。

1 个答案:

答案 0 :(得分:2)

而不是:

document.getElementById('d11').innerHTML=req.responseText;

尝试:

document.getElementById('d11').value=req.responseText;