Me.txtSYONIN_BI_S.Attributes.Add("onfocus", "this.select(); GetFocusId('SYONIN_BI_S'); return false;")
以上是一个txtBox控件,通过JavaScript在这个控件获得焦点的事件中,具体定义处理的内容(GetFocusId方法)。
现在想问的是:
如果是CheckBox控件或者RadioButton控件,有没有获得焦点的事件,有的话是什么?
我试过写Me.rdb_1.Attributes.Add("onfocus", "this.select(); GetFocusId('SYONIN_BI_S'); return false;")不管用。也就是说RadioButton或者CheckBox里面,没有onfocus事件?正确的该怎样写?
谢谢!

解决方案 »

  1.   


    <html>
    <head>
    <script language="javascript">
    [code=JScript]function focusRadAndCbo()
    {
    document.getElementById("rdId2").checked = true;
    document.getElementById("rdId2").focus(); document.getElementById("ckId3").checked = true;
    document.getElementById("ckId3").focus();
    }
    </script>
    </head>
    <body onload="focusRadAndCbo()">
    <form>
    <input type="radio" name="rad" id="rdId1">1
    <input type="radio" name="rad" id="rdId2">2
    <input type="radio" name="rad" id="rdId3">3 <br><br> <input type="checkbox" name="cbo" id="ckId1">1
    <input type="checkbox" name="cbo" id="ckId2">2
    <input type="checkbox" name="cbo" id="ckId3">3
    </form>
    </body>
    </html>
    [/code]
      

  2.   


    <html>
    <head>
    <script language="javascript">function focusRadAndCbo()
    {
    document.getElementById("rdId2").checked = true;
    document.getElementById("rdId2").focus(); document.getElementById("ckId3").checked = true;
    document.getElementById("ckId3").focus();
    }</script>
    </head>
    <body onload="focusRadAndCbo()">
    <form>
    <input type="radio" name="rad" id="rdId1" onfocus="alert(this.name+':'+this.id)">1
    <input type="radio" name="rad" id="rdId2">2
    <input type="radio" name="rad" id="rdId3" onfocus="alert(this.name+':'+this.id)">3 <br><br> <input type="checkbox" name="cbo" id="ckId1" onfocus="alert(this.name+':'+this.id)">1
    <input type="checkbox" name="cbo" id="ckId2" onfocus="alert(this.name+':'+this.id)">2
    <input type="checkbox" name="cbo" id="ckId3">3
    </form>
    </body>
    </html>