0
I created a form with some registration information as a task in my internship job.
This information must be printed in the Console, the problem is in 3 checkbox boxes that I cannot display the selected option in the console.
html.
<div class="col-md-2">
<h5><strong>Serviço:</strong></h5>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
Suporte
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck2">
<label class="form-check-label" for="defaultCheck2">
Desenvolvimento
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck3">
<label class="form-check-label" for="defaultCheck3">
Infraestrutura
</label>
</div>
</div>
Javascript:
function enviar() {
//Variaveis que recebem valor dos inputs e depois são atribuidas ao JSON
var data = $("#inputData").val();
var nome = $("#inputNome").val();
var cep = $("#inputCep").val();
var endereco = $("#inputEndereco").val();
var cidade = $("#inputCidade").val();
var estado = $("#inputState").val();
var bairro = $("#inputBairro").val();
var cnpj = $("#txtCnpj").val();
var preço = $("#inputPreco").val();
var codigo = $("#txtCodigo").val();
var servico = $("#defaultCheck1").val();
//checkbox
var formValue = {
data: data,
name: nome,
endereço: endereco,
cep: cep,
cidade: cidade,
estado: estado,
bairro: bairro,
cnpj: cnpj,
preço: preço,
codigo: codigo,
};
console.log(formValue);
}
worked!! and how can I return "True" on the console to the text of the checkbox ??
– Thiago Medeiros de Lima
@Great. I think that would be a problem for another question, because it involves other operations from there. By the way, if the answer has solved your problem, you can mark it as correct using the V on her left side (only one per question). And welcome to [pt.so].
– Jéf Bueno
Thank you so much for the support, I’m new to development and Stack Overflow!
– Thiago Medeiros de Lima