Advertisement
IstiyakAminSanto

AppendChild for MD Arman

Feb 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>select option for MD Arman</title>
  6. </head>
  7. <body>
  8.  
  9.  
  10. <select id="myList">
  11.     <option>select a year</option>
  12. </select>
  13.  
  14.  
  15.  
  16. <script>
  17. function myFunction() {
  18.     var node = document.createElement("option");
  19.     var node1 = document.createElement("option");
  20.     var node2 = document.createElement("option");
  21.  
  22.     var textnode = document.createTextNode("2017");
  23.     var textnode1 = document.createTextNode("2016");
  24.     var textnode2 = document.createTextNode("2015");
  25.  
  26.     node.appendChild(textnode);
  27.     node1.appendChild(textnode1);
  28.     node2.appendChild(textnode2);
  29.    
  30.     document.getElementById("myList").appendChild(node);
  31.     document.getElementById("myList").appendChild(node1);
  32.     document.getElementById("myList").appendChild(node2);
  33. }
  34. myFunction()
  35. </script>
  36.  
  37.  
  38. </body>
  39. </script>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement