Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Angularjs when clicked table item open edit panel above!"
Bootstrap 3.0.0 Snippet by
muhittinbudak
3.0.0
panel
table
Preview
HTML
View Full Screen
Fork
Fork this
6.7K
 
3 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <body ng-app="myApp" ng-controller="userCtrl"> <div class="w3-container"> <h3>Users</h3> <table class="w3-table w3-bordered w3-striped"> <tr> <th>Edit</th> <th>First Name</th> <th>Last Name</th> </tr> <tr ng-repeat="user in users"> <td> <button class="w3-btn w3-ripple" ng-click="editUser(user.id)">✎ Edit</button> </td> <td>{{ user.fName }}</td> <td>{{ user.lName }}</td> </tr> </table> <br> <button class="w3-btn w3-green w3-ripple" ng-click="editUser('new')">✎ Create New User</button> <form ng-hide="hideform"> <h3 ng-show="edit">Create New User:</h3> <h3 ng-hide="edit">Edit User:</h3> <label>First Name:</label> <input class="w3-input w3-border" type="text" ng-model="fName" ng-disabled="!edit" placeholder="First Name"> <br> <label>Last Name:</label> <input class="w3-input w3-border" type="text" ng-model="lName" ng-disabled="!edit" placeholder="Last Name"> <br> <label>Password:</label> <input class="w3-input w3-border" type="password" ng-model="passw1" placeholder="Password"> <br> <label>Repeat:</label> <input class="w3-input w3-border" type="password" ng-model="passw2" placeholder="Repeat Password"> <br> <button class="w3-btn w3-green w3-ripple" ng-disabled="error || incomplete">✔ Save Changes</button> </form> </div> <script> angular.module('myApp', []).controller('userCtrl', function($scope) { $scope.fName = ''; $scope.lName = ''; $scope.passw1 = ''; $scope.passw2 = ''; $scope.users = [ {id:1, fName:'Hege', lName:"Pege" }, {id:2, fName:'Kim', lName:"Pim" }, {id:3, fName:'Sal', lName:"Smith" }, {id:4, fName:'Jack', lName:"Jones" }, {id:5, fName:'John', lName:"Doe" }, {id:6, fName:'Peter',lName:"Pan" } ]; $scope.edit = true; $scope.error = false; $scope.incomplete = false; $scope.hideform = true; $scope.editUser = function(id) { $scope.hideform = false; if (id == 'new') { $scope.edit = true; $scope.incomplete = true; $scope.fName = ''; $scope.lName = ''; } else { $scope.edit = false; $scope.fName = $scope.users[id-1].fName; $scope.lName = $scope.users[id-1].lName; } }; $scope.$watch('passw1',function() {$scope.test();}); $scope.$watch('passw2',function() {$scope.test();}); $scope.$watch('fName', function() {$scope.test();}); $scope.$watch('lName', function() {$scope.test();}); $scope.test = function() { if ($scope.passw1 !== $scope.passw2) { $scope.error = true; } else { $scope.error = false; } $scope.incomplete = false; if ($scope.edit && (!$scope.fName.length || !$scope.lName.length || !$scope.passw1.length || !$scope.passw2.length)) { $scope.incomplete = true; } }; }); </script> </body> </html>
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76