html - How to add rows and columns dynamically in a listbox in javascript -
i trying create 1500 rows each having 4 column/cells in list box. wanted dynamically. have added listbox using html html
<body onload="load()"> <div id="myform"> <select id ="listid" name="mytable" size="5" style="width: 100px;" > </select> <input type="button" id="create" value="click here" onclick="javascript:addtable()"> <!-- create table , add srows , column javascript --> </div> </body>
javascript note: able create row dont know how create column.
function addtable() { var nofrow = 1500; (var = 0; < nofrow; i++) { var opt = document.createelement("option"); document.getelementbyid("listid").options.add(opt); // (var j = 0; j < noofcell; j++) { // not able figure out add //} }
function addrow(tableid) { var table = document.getelementbyid(tableid); var rowcount = table.rows.length; var row = table.insertrow(rowcount); var cell1 = row.insertcell(0); var element1 = document.createelement("input"); element1.type = "checkbox"; element1.name="chkbox[]"; cell1.appendchild(element1); var cell2 = row.insertcell(1); cell2.innerhtml = rowcount + 1; var cell3 = row.insertcell(2); var element2 = document.createelement("input"); element2.type = "text"; element2.name = "txtbox[]"; cell3.appendchild(element2); }
source dynamically add/remove rows in html table using javascript
Comments
Post a Comment