javascript - Add select dropdown to table column with JS -


i have created table in html (4 rows , 3 columns). want add select dropdown in second column. unable add in column.

my code is:

<!doctype html> <html> <body>  <table border="1" style="width:100%">   <tr>     <th>criteria</th>     <th>yes/no</th>      <th>comments</th>   </tr> <script>  var array1 = [1,2,3,4]; for(var i=0; i<array1.length; i++) {   document.write("<tr>");  document.write("<td>"+array1[i]+"</td>"); document.write("<td>  </td>"); document.write("<td>  </td>");  document.write("</tr>");   } </script> </table> </body> </html> 

and select dropdown html is:

<select name="mydropdown">     <option value="milk">fresh milk</option>     <option value="cheese">old cheese</option>     <option value="bread">hot bread</option> </select> 

this may

<!doctype html>  <html>    <body>      <table border="1" style="width:100%">      <tr>        <th>criteria</th>        <th>yes/no</th>        <th>comments</th>      </tr>      <script>        var array1 = [1, 2, 3, 4];        (var = 0; < array1.length; i++) {            var dropdown = "<select name='mydropdown'>" +            "<option value='milk'>yes</option>" +            "<option value='cheese'>no</option>" +            "</select>";            document.write("<tr>");            document.write("<td>" + array1[i] + "</td>");          document.write("<td>" + dropdown + "</td>");          document.write("<td>  </td>");            document.write("</tr>");            }      </script>    </table>  </body>    </html>


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -