各位大侠,下面代码
  • 标签中的onChange函数为何没响应
  • birney 2011-09-11 05:53:14
    <html>

    <head>
    <script type = "text/javascript">
    var phone_book = new Array();
    phone_book["birney"] = "234343255";
    phone_book["sturm"] = "234394390";
    phone_book["vixtel"] = "343048302";
    pbone_book["jerry"] = "8084032840"
    pbone_book["benson"] = "80899348320";
    function displayNumber( phone_book, entry )
    {
    alert( "hello" );
    //document.write( "<h1>Hey you Guys!</h1>" );
    //var theNumber = phone_book[entry];
    //window.document.the_form.number_box.value = theNumber;
    }
    </script>
    </head>
    <body>
    <form name = "the_form">
    <b>Name:</b>
    <select onChange = "displayNumber( phone_book, this.options[SelectedIndex].value );">
    <option value = "birney">Birney
    <option value = "strum" >Sturm
    <option value = "vixtel">Vixtel
    <option value = "jerry" >Jerry
    <option value = "benson">Benson
    </select>
    <p>
    <b>Number:</b>
    <input type = "text" name = "number_box" value = ""/>
    </form>
    </body>

    </html>
    ...全文
    197 7 打赏 收藏 转发到动态 举报
    写回复
    用AI写文章
    7 条回复
    切换为时间正序
    请发表友善的回复…
    发表回复
    Exodia 2011-09-15
    • 打赏
    • 举报
    回复
    我说,难道不是onchange ?
    birney 2011-09-15
    • 打赏
    • 举报
    回复
    多谢各位了。。。。。
    寒似火 2011-09-15
    • 打赏
    • 举报
    回复

    <html>
    <head>
    <script type = "text/javascript">
    var phone_book = new Array();
    phone_book["birney"] = "234343255";
    phone_book["strum"] = "234394390";
    phone_book["vixtel"] = "343048302";
    phone_book["jerry"] = "8084032840"
    phone_book["benson"] = "80899348320";
    function displayNumber(entry)
    {
    var theNumber = phone_book[entry.value];
    window.document.the_form.number_box.value = theNumber;
    }
    </script>
    </head>
    <body>
    <form name = "the_form">
    <b>Name:</b>
    <select onChange = "displayNumber(this);">
    <option value = "birney">Birney
    <option value = "strum" >Sturm
    <option value = "vixtel">Vixtel
    <option value = "jerry" >Jerry
    <option value = "benson">Benson
    </select>
    <p>
    <b>Number:</b>
    <input type = "text" name = "number_box" value = ""/>
    </form>
    </body>
    </html>
    最后一个菜鸟 2011-09-12
    • 打赏
    • 举报
    回复
    [Quote=引用 3 楼 fanchuanzhidu 的回复:]

    HTML code
    <html>

    <head>
    <script type = "text/javascript">
    var phone_book = new Array();
    phone_book["birney"] = "234343255";
    phone_book["sturm"] = "234394390";
    phone_book["vixtel"] = "343048302";
    ph……
    [/Quote]
    selectedIndex前面要不要加个this啊
    豆虫 2011-09-11
    • 打赏
    • 举报
    回复
    <html>

    <head>
    <script type = "text/javascript">
    var phone_book = new Array();
    phone_book["birney"] = "234343255";
    phone_book["sturm"] = "234394390";
    phone_book["vixtel"] = "343048302";
    phone_book["jerry"] = "8084032840"
    phone_book["benson"] = "80899348320";
    function displayNumber( phone_book, entry )
    {
    alert( "hello" );
    //document.write( "<h1>Hey you Guys!</h1>" );
    //var theNumber = phone_book[entry];
    //window.document.the_form.number_box.value = theNumber;
    }
    </script>
    </head>
    <body>
    <form name = "the_form">
    <b>Name:</b>
    <select onChange = "displayNumber( phone_book, this.options[selectedIndex].value );">
    <option value = "birney">Birney
    <option value = "strum" >Sturm
    <option value = "vixtel">Vixtel
    <option value = "jerry" >Jerry
    <option value = "benson">Benson
    </select>
    <p>
    <b>Number:</b>
    <input type = "text" name = "number_box" value = ""/>
    </form>
    </body>

    </html>
    BLUE_LG 2011-09-11
    • 打赏
    • 举报
    回复
    还有你的phone有的写成pbone了。。。
    BLUE_LG 2011-09-11
    • 打赏
    • 举报
    回复
    selectedIndex应该是这样写。。。

    87,990

    社区成员

    发帖
    与我相关
    我的任务
    社区描述
    Web 开发 JavaScript
    社区管理员
    • JavaScript
    • 无·法
    加入社区
    • 近7日
    • 近30日
    • 至今
    社区公告
    暂无公告

    试试用AI创作助手写篇文章吧