现页面中,我在一个text输入框输入内容,现需:
每输入一个字或输入一个字母就要调用此页面的一个javascript方法,方法名为 view_all()这如何实现呀,在线等

解决方案 »

  1.   

    <input type='text' onchange="view_all();"/>
      

  2.   

    <input type=text onkeyup='view_all(this)'>
      

  3.   

    HTML 限制文本框只能输入数字 onkeyup+onafterpaste限制文本框只能输入数字
    <input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
    <input name=txt1 onchange="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}">
      

  4.   

    这个 text  onfocus 时候注册 onKeyDown事件为你的函数。
      

  5.   

    var mytime;
    function checkanswer(){
    var xmlHttp = GetXmlHttpRequest();
    var url = "fun/answer_check.php?cfgId=<?php echo $cfgId;?>";
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange = function(){
    if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
    if(xmlHttp.responseText >0){
    clearInterval(mytime);
    location.href="ifr_active_tip.php?userId="+xmlHttp.responseText;
    }
    }
    }
    xmlHttp.send(null);
    }
    //定时器
    mytime = setInterval('checkanswer()',1000);