-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathknapsackview.php
97 lines (93 loc) · 2.82 KB
/
knapsackview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<html ng-app>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>KnapSack</title>
<link href='https://fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script type="text/javascript">
//script ANGULARJS
var principal = function($scope){
$scope.items = [];//cria array
$scope.add = function (index) {
$scope.items.push({ //insere valor no array
indexvalue: index
});
};
$scope.limpar = function () {
$scope.items = [];//limpa array
$scope.add(-1);//adiciona novo valor no array
};
$scope.remover = function(index){
$scope.items.splice(index, 1);//remove do array
if($scope.items.length == 0)
{
$scope.add(-1);//adiciona valor no array
}
}
$scope.add(-1);//adiciona valor no array na inicialização da tela
}
</script>
<div ng-controller="principal" class="form">
<form action="knapsack.php" method="POST" target="_blank">
<table class="table">
<tr>
<th>KNAPSACK (Mochila)</td>
<tr>
<td>
<fieldset class="field">
<table align="center">
<tr>
<td>
<p>Peso Maximo Mochila: </p>
</td>
<td>
<input name="pesomaximo" type="number" id="pesomaximo" tabindex="1" size="70">
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset class="field"><legend>Itens</legend>
<br/>
<table align="center">
<tr>
<td>
<div ng-repeat="item in items" class="item">
Item: {{$index + 1}} | Peso: <input name="peso[]" type="number" id="peso" tabindex="2" size="20" > | Custo: <input name="custo[]" type="number" id="custo" tabindex="2" size="5">
<input type="button" id="btnRemover" value="Remover" style="width: 70px; height: 23px;" ng-click="remover($index)">
<br/>
</div>
</td>
<td>
<table class="botao">
<tr>
<td><input type="button" id="btnAdicionar" tabindex="-1" value="Adicionar" style="width: 100px; height: 30px;" ng-click="add()"></td>
</tr>
<tr><td></td></tr>
<tr>
<td><input type="button" id="btnLimpar" tabindex="-1" value="Limpar Tudo" style="width: 100px; height: 30px;" ng-click="limpar()"></td>
</tr>
</table>
</td>
</tr>
</table>
<table class="botao">
<tr>
<td><input type="submit" tabindex="-1" value="PROCESSAR" ></td>
</tr>
</table>
</fieldset>
</td>
</tr>
</tr>
</table>
</form>
</div>
</body>
</html>