www.webdeveloper.com
Results 1 to 7 of 7

Thread: create a row using checkboxes

Threaded View

  1. #1
    Join Date
    Aug 2004
    Posts
    195

    create a row using checkboxes

    Im trying to figure out how to use checkboxes to add rows (up to five) to an existing table, heres the html,
    HTML Code:
    <form name="myform">
    Row 1 <input type="checkbox" name="check_list" onClick="addRow(1)"><br>
    Row 2 <input type="checkbox" name="check_list" onClick="addRow(3)"><br>
    Row 3 <input type="checkbox" name="check_list" onCheck="addRow(3)"><br>
    Row 4 <input type="checkbox" name="check_list" onCheck="addRow(4)"><br>
    Row 5 <input type="checkbox" name="check_list" onCheck="addRow(5)"><br>
    <button type="button"onClick="CheckAll(document.myform.check_list)">Check All</button>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onClick="UnCheckAll(document.myform.check_list)">Unheck All</button>
    </form> 
       <table id="dynamo" align="center" border="0" cellpadding="0" cellspacing="0">
    	<tr>
    	<th>&nbsp;</th>
    	<th>Column 1</th>
    	<th>Column 2</th>	
    	<th>Column 3</th>	
    	</tr>	
    	</table>
    heres the function to create the row
    Code:
    function addRow(x)
    {
    var mytable = document.getElementById("dynamo");
    
    var row=document.createElement("tr");
    var col1=document.createElement("td");
    var rowcount=document.createTextNode("Row "+x);
    var col2=document.createElement("td");
    var col3=document.createElement("td");
    var col4=document.createElement("td");
    
    col1.appendChild(rowcount);
    
    mytable.appendChild(row);
    mytable.appendChild(col1);
    mytable.appendChild(col2);
    mytable.appendChild(col3);
    mytable.appendChild(col4);
    }
    I'm trying to get all the borders to show (even the tds with no content)
    Also, im trying to toggle the rows, so if the box isn't checked the row goes away.
    javascriptss.png
    Thanks...
    Last edited by lukeurtnowski; 06-05-2014 at 05:40 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles