单击一个textbox后显示一个DIV供用户选择一个数据赋值到textbox中后隐藏该DIV,现在的问题是除单击DIV和textbox外的所有控件都要隐藏该DIV,也就是说单击DIV(选中数据除外)和textbox不隐藏DIV,其他情况都要隐藏该DIV,请大家帮我个忙吧  最好能给出代码或是例子,谢谢大家了,,,

解决方案 »

  1.   

    <!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 runat="server">
        <title>無題のページ</title>    <script language="javascript" type="text/javascript">
        function setFunction(obj)
        {
            if(document.getElementById("selectBar").style.display == "none")
            {
                document.getElementById("selectBar").style.display = "block";                   
                document.getElementById("t1").value ="";
            }
            else
            {
                document.getElementById("selectBar").style.display = "none";
            }
        }
        
        function setValueToText(obj)
        {
            document.getElementById("t1").value  = obj.options[obj.selectedIndex].value;
            document.getElementById("selectBar").style.display = "none";
        }
        
        </script></head>
    <body>
        <form id="form1" runat="server">
            <table>
                <tr>
                    <td>
                        <input type="text" id="t1" name="test1" onclick="setFunction();" runat="server" />
                    </td>
                    <td>
                        <div id="selectBar" style="display :none;">
                            <select onchange="setValueToText(this);" visible="false">
                                <option value="1111111111111">1111111111111</option>
                                <option value="2222222222222">2222222222222</option>
                                <option value="3333333333333">3333333333333</option>
                                <option value="4444444444444">4444444444444</option>
                                <option value="5555555555555">5555555555555</option>
                                <option value="6666666666666">6666666666666</option>
                                <option value="7777777777777">7777777777777</option>
                            </select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="t2" name="test1" runat="server" />
                    </td>
                </tr>           
            </table>        
        </form>
    </body>
    </html>
    随手做了做,你自己再看看吧`
      

  2.   

    上面的例子似乎不行,当t2获得焦点时,DIV不会隐藏,同时单击其他区域DIV没有隐藏,,上面的大哥能不能再看看
      

  3.   

    avon520    能说得更清楚些吗?最好能给出一个例子来,,谢谢了