Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>boodschappenlijst</title>
  5.  
  6. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8.  
  9. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  10. <link rel="stylesheet" href="./css/style.css">
  11. </head>
  12. <body>
  13. <div class="container-fluid">
  14. <div class="row">
  15. <div class="col-6">
  16. <div class="input-group">
  17. <input type="text" class="form-control" id="Arrayadd" placeholder="nieuw product">
  18. <span class="input-group-btn">
  19. <button class="btn btn-primary" type="button" onclick="addIntoArray();">Toevoegen</button>
  20. </span>
  21. <button class="btn btn-primary" type="button" onclick="remove1();">verwijder bovenste</button>
  22. <button class="btn btn-primary" type="button" onclick="remove2();">verwijder onderste</button>
  23. </div>
  24. </div>
  25. <div class="col-6"><h1><b>Boodschappenlijstje</b></h1>
  26.  
  27. <ol id="outputElement"></ol>
  28. </div>
  29. </div>
  30. </div>
  31.  
  32.  
  33. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  34. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
  35. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  36. </body>
  37. </html>
  38. <script>
  39. var arrayTest = new Array();
  40. var output = document.getElementById("outputElement");
  41. var inputElement = document.getElementById("Arrayadd");
  42.  
  43. function remove1() {
  44. arrayTest.splice(0, 1);
  45. showArray();
  46. }
  47.  
  48. function remove2(){
  49. arrayTest.splice(-1, 1);
  50. showArray();
  51. }
  52.  
  53.  
  54. function addIntoArray() {
  55. if(inputElement.value != "") {
  56. arrayTest.push(inputElement.value);
  57. document.getElementById("Arrayadd").value = "";
  58. showArray();
  59. }
  60. }
  61.  
  62. function showArray() {
  63. var outputVar = "";
  64. for(var i = 0; i < arrayTest.length; i++) {
  65. outputVar += "<li>"+arrayTest[i]+"</li>";
  66. }
  67. output.innerHTML = outputVar;
  68. }
  69. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement