javascript

  • After moving the data finally if I click submit button I want to get right side table key value in an array.
  • How can I move table row data from one table to another table using as per the buttons.
  • var app = angular.module(‘myApp’, []); function checkBoxCtrl($scope) { $scope.tableOne = [{ key: ‘1’, value: ‘a’ }, { key: ‘2’, value: ‘b’ }, { key: ‘3’, value: ‘c’ }, { key: ‘4’, value: ‘d’ } ]; $scope.tableTwo = [];//the table to be submitted function removeitems(tableRef) { //revmove items from tableRef var i; for (i = tableRef.length – 1; i >= 0; i -= 1) { if (tableRef[i].
  • after i click that submit button i want to show firstname with close button below the table.
  • Searching pls edit my fiddle – mahesh k 5 hours ago

However , I do not understand the functionality of ‘btnRight’ and ‘btnLeft’. On click , do you want to move the first item or last?

@webpoint_new: #wp_Dev #ajax #stackoverflow moving data tabte to table in angularjs

{{data.key}} {{data.value}}

var app = angular.module(‘myApp’, []); function checkBoxCtrl($scope) { $scope.tableOne = [{ key: ‘1’, value: ‘a’ }, { key: ‘2’, value: ‘b’ }, { key: ‘3’, value: ‘c’ }, { key: ‘4’, value: ‘d’ } ]; $scope.tableTwo = [];//the table to be submitted function removeitems(tableRef) { //revmove items from tableRef var i; for (i = tableRef.length – 1; i >= 0; i -= 1) { if (tableRef[i].checked) { tableRef.splice(i, 1); } } } $scope.btnRight = function () { //Loop through tableone $scope.tableOne.forEach(function (item, i) { // if item is checked add to tabletwo if (item.checked) { $scope.tableTwo.push(item); } }) removeitems($scope.tableOne); } $scope.btnAllRight = function () { $scope.tableOne.forEach(function (item, i) { item.checked = true; $scope.tableTwo.push(item); }) removeitems($scope.tableOne); } $scope.btnLeft = function () { $scope.tableTwo.forEach(function (item, i) { if (item.checked) { $scope.tableOne.push(item); } }) removeitems($scope.tableTwo); } $scope.btnAllLeft = function () { $scope.tableTwo.forEach(function (item, i) { item.checked = true; $scope.tableOne.push(item); }) removeitems($scope.tableTwo); } $scope.submit = function () { alert(angular.toJson($scope.tableTwo)) } };

HTML: Table One

{{data.key}} {{data.value}}


Table Two

{{data.key}} {{data.value}}

JS: var app = angular.module(‘myApp’, []); function checkBoxCtrl($scope){ $scope.tableOne=[ {key: ‘1’, value: ‘a’}, {key: ‘2’, value: ‘b’}, {key: ‘3’, value: ‘c’}, {key: ‘4’, value: ‘d’} ]; $scope.table2=[]; $scope.btnRight = function () { } $scope.btnAllRight = function () { $scope.table2=$scope.tableOne; $scope.tableOne=[]; } $scope.btnLeft = function () { } $scope.btnAllLeft = function () { $scope.tableOne=$scope.table2; $scope.table2=[]; } };

javascript

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.