JS如何给客户端下拉菜单增加选项

解决方案 »

  1.   


    var oOption = document.createElement("OPTION");
    oOption.text = "法拉利";
    oOption.value = "4";document.getElementById("selectid").options.add(oOption);
      

  2.   


    <!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>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     </head>
     <body>
      <form method="post" action="">
    <select id="DropDownList">
    </select>
      </form>
      <script type="text/javascript">
      <!--
    //------------------------------------------------------
    // 你可以用document.getElementById()方法
    // 然后像楼上那样。也可以简单的加一句如下
    // 注:语法-- new Option(Text,Value)
    //------------------------------------------------------
    document.all.DropDownList.options.add(new Option("请选择...","-1"));
      //-->
      </script>
     </body>
    </html>
      

  3.   

    document.all.XXIE的,1楼的方法是通用的 ,符合W3C