0
I have a simple code in JS, and would like to analyze the browser console, but as soon as the code runs the function it gives Reload on the page.
Complete code
HTML
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<h4>Novo Grupo</h4>
<div class="ibox-content">
<form id="formGrupo" method="get" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">Nome do grupo</label>
<div class="col-sm-10">
<input style="color: #676a6c;" id="nomeGrupo" type="text" placeholder="Nome do Grupo" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Selecionar Parceiros</label>
<div class="col-sm-5">
<div class="list-group" id="selectable">
<a href="#" class="list-group-item">Parceiro 1</a>
<a href="#" class="list-group-item">Parceiro 2</a>
<a href="#" class="list-group-item">Parceiro 3</a>
<a href="#" class="list-group-item">Parceiro 4</a>
<a href="#" class="list-group-item">Parceiro 5</a>
</div>
</div>
<div class="col-sm-5">
<div class="list-group" id="selectable">
<div class="lista-parceiros">
<div id="grupo-parceiros"></div>
</div>
</div>
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<button type="submit" onclick="enviar()" class="btn btn-primary">Novo Grupo</button>
</div>
</div>
</form>
</div>
</div>
</div>
JS
<script>
var nomeGrupo = document.getElementById('nomeGrupo');
var prcGrupo = document.getElementsByClassName("ui-selected");
var vetor = new Array();
var i;
function enviar() {
for (i = 0; i <= prcGrupo.length; i++){
vetor[i] = prcGrupo.value;
}
console.log(nomeGrupo);
console.log(vetor.value);
//alert('Nome do grupo: ' + nomeGrupo.value);
//alert('Parceiros: ' + vetor);
return alert(vetor.value);
}
Where is this function called?
– adventistaam
face is incomplete your question, where does the id name Group? and where is declared the class ui-Lected ?
– Julio Henrique
On a button <button type="Submit" onclick="send()" class="btn btn-Primary">New Group</button>
– Marcus Botelho
this Ubmit that is doing the recharging, try to change the
<a href="#" class="btn btn-primary">Novo grupo</a
– adventistaam