Help me please
I’m using this code like a form forward to google sheet.
in this code i have 13 check box but when i submit is filled all “ch[]” in sheet, not one or two checked. Therefore i understood that each one ch[] have a value but how can i resolve this issue?
I need forward to the sheets just the checked boxes
<form
method="POST"
action="https://script.google.com/macros/s/00000000000000000000000000000000/exec">
<input type="text" required="" name="nome" placeholder="Digite seu Nome aqui">
<input type="number" pattern="^d{11}$" required="" name="telefone" placeholder="DDD + Nº celular">
<input type="e-mail" name="email" placeholder="Email (opcional)"><br><br>
DIGITE SEU ENDEREÇO <input type="text" required="" name="endereço" placeholder="rua,nº,bairro cidade"><br>
COPIE E COLE O ENDEREÇO DO MAPA <input type="url" name="end" placeholder="Localização (opcional)"><br><br>
<label>HATCH <input type="checkbox" name="ch[]" value="60" /></label>
<label>SEDAN <input type="checkbox" name="ch[]" value="60" /></label>
<label>CROSSOVER <input type="checkbox" name="ch[]" value="60" /></label>
<label>SUV <input type="checkbox" name="ch[]" value="60" /></label>
<label>MINIVAN <input type="checkbox" name="ch[]" value="70" /></label>
<label>PICUP <input type="checkbox" name="ch[]" value="70" /></label>
<label>STATION WAGON <input type="checkbox" name="ch[]" value="70" /></label>
<label>CONVERSÍVE <input type="checkbox" name="ch[]" value="70" /></label>
<label>CUPE <input type="checkbox" name="ch[]" value="70" /></label>
<label>LUXO <input type="checkbox" name="ch[]" value="70" /></label><br><br>
<p>ADICIONAIS</p><br>
<label>LAVAGEM (SECO) DE MOTOR <input type="checkbox" name="ch[]" value="20" /></label>
<label>CERA PLUS <input type="checkbox" name="ch[]" value="30" /></label>
<label>CHEIRINHO <input type="checkbox" name="ch[]" value="10" /></label>
<label>VALOR <input type="text" name="result" id="result" value="R$ 0,00" /></label><br>
<input type="submit" value="ENVIAR">
</form>
</FONT>
</h2>
<script>
String.prototype.formatMoney = function() {
var v = this;
if(v.indexOf('.') === -1) {
v = v.replace(/([d]+)/, "$1,00");
}
v = v.replace(/([d]+).([d]{1})$/, "$1,$20");
v = v.replace(/([d]+).([d]{2})$/, "$1,$2");
v = v.replace(/([d]+)([d]{3}),([d]{2})$/, "$1.$2,$3");
return v;
};
String.prototype.toFloat = function() {
var v = this;
if (!v) return 0;
return parseFloat(v.replace(/[D]+/g, '' ).replace(/([d]+)(d{2})$/, "$1.$2"));
};
(function(){
"use strict";
var $chs = document.querySelectorAll('input[name="ch[]"]'),
$result = document.getElementById('result'),
chsArray = Array.prototype.slice.call($chs);
chsArray.forEach(function(element, index, array){
element.addEventListener("click", function(){
var v = this.value,
result = 0;
v = v.toFloat();
if (this.checked === true) {
result = $result.value.toFloat() + parseFloat(v);
} else {
result = $result.value.toFloat() - parseFloat(v);
}
$result.value = "R$ " + String(result).formatMoney();
});
});
}());
</script>
<script>
document.querySelector('#submit').addEventListener('click',function(){
let cliente = document.querySelector('#nome').value;
let sobrenome = document.querySelector('#sobrenome').value;
let email = document.querySelector('#email').value;
let telefone = document.querySelector('#telefone').value;
let exampleFormControlSelect1 = document.querySelector('#exampleFormControlSelect1').value;
window.open(url);
});
</script>