JS - After creating a new row; how do I select a different column?

Choppa

www.warcraft-gamers.po.gs
Reaction score
59
PHP:
<script language="javascript" type="text/javascript">

function addChkBx_onclick(){
	var table = document.getElementById('thing');
	var newTH = document.createElement('td');
	var lastTableRow = table.insertRow();
		var lastCreatedRow = table.document.createElement('td');
		lastTableRow.innerHTML = "<input type='checkbox'/>";
}
</script>

I also want to insert a textbox next to that, I have a table with 2 columns and I want to insert a textbox in the second column, how would I go about doing this?
 

enouwee

Non ex transverso sed deorsum
Reaction score
239
Is this what you want?

Code:
function addChkBx_onclick(){
        var table = document.getElementById('thing');
        var allTableRows = document.getElementById("thing").rows;       
        var lastTableRow = table.insertRow(allTableRows-1);

        td = document.createElement('td');
        td.innerHTML = "<input type='checkbox' />";
        lastTableRow.appendChild(td);

        td = document.createElement('td');
        td.innerHTML = "<input type='text' />";
        lastTableRow.appendChild(td);
}
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top