• select动态增加option


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>

    <title>option creation</title>

    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

    <style type="text/css">

    /*<![CDATA[*/

    body {

         

     }

    #container {

         400px;

         text-align:center;

         padding: 20px 0px;

         border: 3px double #000;

         

         margin:30px auto;

     }

    /*//]]>*/

    </style>

    <script type="text/javascript">

    //<![CDATA[

      var opts=3  /*number of original options*/

      var df=document.forms;

    function optionAdd(num) { 

       opts=opts+num;

       df[0][0].options.length=opts;

       df[0][0].options[opts-1].innerHTML=df[0][1].value;

       df[0][1].value=""

     }

    //]]>

    </script>

    </head>

    <body>

    <form action="#">

    <div id="container">

    <select>

      <option>- - - - - - - - </option>

      <option>option one</option>

      <option>option two</option>

    </select>

    <input type="text" />

    <input type="button" value="new option" onclick="optionAdd(1)"/>

    </div>

    </form>

    </body>

    </html>

  • 相关阅读:
    topcoder srm 681 div1
    topcoder srm 683 div1
    topcoder srm 684 div1
    topcoder srm 715 div1
    topcoder srm 685 div1
    topcoder srm 687 div1
    topcoder srm 688 div1
    topcoder srm 689 div1
    topcoder srm 686 div1
    topcoder srm 690 div1 -3
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/4096652.html
Copyright © 2020-2023  润新知