Dynamic Add option is more practical in some special cases, this article has a small example for you to introduce the next createelement use, interested friends can refer to the following
Code as follows: <! DOCTYPE html> <html> <head> <title>select.html</title> <meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" > <meta http-equiv= "description" Content= "This are my page" > <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "> <!--<link rel=" stylesheet "type=" Text/css "href="./styles.css ">--> </head> <body> <select id = "Mycourse" onchange = "getcourse ();" > <option value = "" selected>--Please select a course--</option> </select> < TextArea id = "Myares" rows= "ten" cols= "></textarea> <script type=" text/javascript "type =" text/ JavaScript "> <!-- var last_select_num = 3;//Join query from database //Dynamically add first course var myoption = doc Ument.createelement ("option"); myoption.value = "java"; myoption.text = "java"; &nbsP Mycourse.add (myoption); //Dynamically add second course, myoption = document.createelement ("option"); Myoption.value = "Oracle"; myoption.text = "Oracle"; Mycourse.add (myoption); //Dynamic Add Third course, Myoption = document.createelement ("option"); myoption.value = "java ee"; myoption.text = "java ee"; nbsp Mycourse.add (myoption); function GetCourse () { myares.value = "you selected:" +mycourse.value + "rn"; } --> </script> </body> </html>