0
I have a form with 60 input textbox with name number[], of those 60 numbers I can only select a quantity x( quantity can be variable ); as I do for when the user unchecks the checkbox the number is removed from the array ?
var i = 0,
selecionados = [],
maximo = {
{
$dados - > numeros
}
},
input = 0;
Array.prototype.remove = function() {
var what, a = arguments,
L = a.length,
ax;
while (L && this.length) {
what = a[--L];
while ((ax = this.indexOf(what)) !== -1) {
this.splice(ax, 1);
}
}
return this;
};
//***************************************************************
function selecione(valor) {
selecionados.push(valor);
for (i = 1; i < selecionados.length; i++) {
if (selecionados[valor] == valor) {
selecionados.remove('' + valor);
alert('ok');
console.clear();
console.log(selecionados);
}
}
console.log(selecionados);
}
<div class="container-fluid">
<form name="form" action="{{ route('aposta.salvar')}}" method="POST">
<input type="hidden" name="numeros" value="{{ $dados->numeros }}">
<input type="hidden" name="cotacao" value="{{ $dados->cotacao }}"> @for ($i = 1; $i
< 61; $i++) <div class="col-md-1">
<input type="checkbox" onclick="selecione({{$i}})" id="{{$i}}" name="numero[]" value="{{ ($i < 10) ? (0 . $i) : $i }}" />
<div class="box box-primary checkbox" id="box-{{ $i }}" type="checkbox">
<div class="box-body box-profile">
<h5 class="text-center">{{ ($i
< 10) ? (0 . $i) : $i }}</h5>
</div>
</div>
</div>
@endfor
<div class="btn-inline">
<a href="#" onClick="history.go(0)" class="btn btn-warning ">Limpar</a>
<a href="#" onclick="gerar()" class="btn btn-danger">Gerar</a>
<button type="submit" class="btn btn-primary btn-flat">Proximo</button>
</div>
</form>
</div>