javascript table handling

I have two tables on a html page, the original table will be filled by a DB2 results but on each row of this table I need to add a Add button which will add that row into a new table, and in this new table, I need to add two new check boxes and a Remove button, which when clicked need to remove the row from this table and add this to the source table back ....

Can any one post the HTML and the JS ...
raviraghuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
if you're able to use jquery, there are tons of table components out there such as datatables and jqGrid
0
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
datatables is the more "popular" one, although I find it a bit difficult to set up. jqGrid I think is much easier to implement and has the same features of most of the components out there
0
RobOwner (Aidellio)Commented:
http://jsbin.com/tisohu/1/edit

This is where knockoutjs is so good in that you can capture that logic you're trying to achieve and control it in code rather than messy html:

$(function() {
	viewModel = {
		sourceTable: ko.observableArray([
			'row1','row2','row3','row4'
		]),
		destTable: ko.observableArray([])

	};

	viewModel.addRow = function(r) {
		viewModel.sourceTable.remove(r);
		viewModel.destTable.push(r);
	};
	
	viewModel.removeRow = function(r) {
		viewModel.sourceTable.push(r);
		viewModel.destTable.remove(r);
	};

	ko.applyBindings(viewModel);
});

Open in new window


		<table border="1">
			<thead>
				<tr>
					<td>Table 1</td>
				</tr>
			</thead>
			<tbody data-bind="foreach: sourceTable">
				<tr>
					<td data-bind="text: $data"></td>
					<td><button data-bind="click: $root.addRow">Add</button></td>
				</tr>
			</tbody>
		</table>
		<p></p>
		<table border="1">
			<thead>
				<tr><td>Table 2</td></tr>
			</thead>
			<tbody data-bind="foreach: destTable">
				<tr>
					<td data-bind="text: $data"></td>
					<td><input type="checkbox" name="checkbox1" value="yes" /><input type="checkbox" name="checkbox1" value="no"/></td>
					<td><button data-bind="click: $root.removeRow">Remove</button></td>
				</tr>
			</tbody>
		</table>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.