如网页有控件
1 2 3 4 5 6 7 8 9 0然后有两个文本框
T1  T2
当我的鼠票在T1时 点击控件1就把1赋值给T1
当我的鼠票在T2时 点击控件1就把1赋值给T2谢谢

解决方案 »

  1.   

    你点击 你的控件1的时候 实际上 焦点已经从t1移到了控件1上网页是按焦点的来算当前操作的控件的
    楼主要实现你的功能 应该用一个 隐藏框 在焦点到t1时候保存 id为t1
    点击你的控件1时候 根据这个隐藏框来 赋值给t1或t2
      

  2.   

    在javascript中声明一个全局变量selID,T1和T2的onfocus中记录下选中的ID,在0~9的onclick中取值赋给selID记录的变量。
      

  3.   

    this.L1.Attributes.Add("onmouseover","if(document.all.T1.focus){document.all.T1.value='1'};");
    this.L1.Attributes.Add("onmouseout","document.all.T1.value='';document.all.T2.value=''");
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Test</title>
    <script language="javascript">
    var focusText;
    function textOnFocus(id)
    {
    focusText=id;
    }
    function btClick(str)
    {
    if(focusText!=null)
    {
    document.getElementById(focusText).value=str;
    }
    }

    </script>
    </head><p>
    <input name="bt1" type="button" value="1" id="bt1" onclick="btClick(this.value);"/>
    <input name="bt2" type="button" value="2" id="bt2" onclick="btClick(this.value);"/>
    <input name="bt3" type="button" value="3" id="bt3" onclick="btClick(this.value);"/>
    <input name="bt4" type="button" value="4" id="bt4" onclick="btClick(this.value);"/>
    <input name="bt5" type="button" value="5" id="bt5" onclick="btClick(this.value);"/>
    <input name="bt6" type="button" value="6" id="bt6" onclick="btClick(this.value);"/>
    <input name="bt7" type="button" value="7" id="bt7" onclick="btClick(this.value);"/>
    <input name="bt8" type="button" value="8" id="bt8" onclick="btClick(this.value);"/>
    <input name="bt9" type="button" value="9" id="bt9" onclick="btClick(this.value);"/>
    <input name="bt0" type="button" value="0" id="bt0" onclick="btClick(this.value);"/></p>
    <p><input name="t1" id="t1" type="text" onfocus="textOnFocus(this.id);"/>
    <input name="t2" id="t2" type="text" onfocus="textOnFocus(this.id);"/>
    </p><body>
    </body>
    </html>
      

  5.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title> 
      <script type="text/javascript">
      <!--
    function focusID(_ID)
    {
                 //安装楼主意思是鼠标悬停 应该是onmouseover 但是对于实际操作应该onfocus更适合
    document.getElementById('curTID').value = _ID;
    }
    function setText(val)
    {
    var txtID = document.getElementById('curTID').value;
    document.getElementById(txtID).value = val;
    }
      //-->
      </script>
     </head> <body>
      T1: <input type="text" id="t1" onmouseover="focusID(this.id);" /><br />
      T2: <input type="text" id="t2" onmouseover="focusID(this.id);" /><input type="hidden" id="curTID" value="" /><br />
      <input type="button" id="btn01" value="test1" onclick="setText(this.value);" /><br />
      <input type="button" id="btn02" value="test2" onclick="setText(this.value);"/><br />
      <input type="button" id="btn03" value="test3" onclick="setText(this.value);"/><br />
      <input type="button" id="btn04" value="test4" onclick="setText(this.value);"/>......<br />
     </body>
    </html>