-1
I have this problem, because it is not returning anything and trying to find everywhere, but nothing solution so far I will post the codes of my tests.
Follows:
function calculo(){
if (formulario.nome_para.value=="") {
alert("Preencha seu nome corretamente.");
formulario.nome_para.focus();
return false }
if (formulario.seu_email.value=="") {
alert("Preencha seu e-mail corretamente.");
formulario.seu_email.focus();
return false }
if (formulario.telefone.value=="") {
alert("Preencha seu telefone corretamente.");
formulario.telefone.focus();
return false }
if (formulario.endereco.value=="") {
alert("Preencha seu endereço corretamente.");
formulario.endereco.focus();
return false }
if (formulario.cidade.value=="") {
alert("Preencha sua cidade corretamente.");
formulario.cidade.focus();
return false }
if (formulario.comoConhece.value=="") {
alert("Preencha o campo como conheceu a gente.");
formulario.comoConhece.focus();
return false }
var buscaOptionOb = document.getElementById("TipoObra");
var TipoObra = buscaOptionOb.options[buscaOptionOb.selectedIndex].value;
var metro2 = formulario.m2.value;
var limMetro2 = str.match([0-9]/",");
var idadeEd = formulario.idadeEdifica.value;
var limIdadeEd = str.match([0-9]/",");
var tipoObra = formulario.TipoObra.value;
var calValRef = tipoObra*limMetro2;
if(limIdadeEd>10){
calIdade=calValRef*1.2;
}else{
calIdade=0;
}
if (formulario.reforcoEstru[0].checked) {
calReforco=calValRef*75.00
}else{
calReforco=0;
}
var calTot=calIdade+calReforco+calValRef;
document.getElementById('calTotal').value = calTot;
}
<form onsubmit="return calculo(this);" id="formulario" action="calculoMinuto1.php" method="post">
<div class="col1E">
<select id="TipoObra" name="valores">
<option value="Tipo de obra">Tipo de obra</option>
<option value="Reforma residencial - Casa">Reforma residencial - Casa</option>
<option value="Reforma residencial - Apartamento">Reforma residencial - Apartamento</option>
<option value="Reforma Comercial - Apartamento">Reforma Comercial - Apartamento</option>
<option value="Reforma Comercial - Casa">Reforma Comercial - Casa</option>
<option value="Execução de uma nova residência">Execução de uma nova residência</option>
<option value="Execução de um novo Galpão">Execução de um novo Galpão</option>
<option value="Execução de um novo estabelecimento comercial">Execução de um novo estabelecimento comercial</option>
</select>
<br />
<input type="text" name="idadeEdifica" id="idadeEdifica" placeholder="Idade edificação" onKeyUp="mascaraAno(this, event)" value="">
<br />
<input type="text" name="m2" id="m2" placeholder="m²" onKeyUp="maskIt(this,event,'###.###.###,## m2',true)" value="">
<br />
<select id="reforcoEstru" name="reforcoEstru">
<option value="">Reforço estrutural</option>
<option value="Sim">Sim</option>
<option value="Não">Não</option>
</select>
<br />
<input name="comoConhece" id="comoConhece" type="text" class="campo-simples" placeholder="Como nos conheceu?" />
</div>
<div class="col2D">
<input name="nome_para" id="nome_para" type="text" class="campo-simples" placeholder="Seu nome" />
<br />
<input name="seu_email" id="seu_email" type="text" class="campo-simples" placeholder="E-mail" />
<br />
<input name="telefone" id="telefone" type="text" class="campo-simples" id="telefone" placeholder="Telefone" maxlength="15" minlength="10"/>
<br />
<input name="endereco" id="endereco" type="text" class="campo-simples" placeholder="Endereço da obra" />
<br />
<input name="cidade" id="cidade" type="text" class="campo-simples" placeholder="Cidade" />
</div>
<div class="col3T">
<textarea name="mensagem" rows="3" cols="40" rows="10" class="campo-mensagem" placeholder="Mensagem"></textarea>
<br />
<strong>Adicionar arquivo</strong><br />
<input name="arquivo" type="file" class="campo-simples" />
<br />
<input name="Submit" type="submit" class="campo-envia" value="Enviar" />
</div>
<input name="assunto" type="hidden" class="campo-cinza" value="Formulario de Orcamento Minuto" />
<input name="email" type="hidden" class="campo-cinza"value="[email protected]" />
<input name="calTotal" id="calTotal" type="hidden" class="campo-cinza" value="" />
<input type="hidden" name="encoding" value="UTF-8">
</form>
JS Code: https://pastebin.com/CqpqL19N Html code: https://pastebin.com/HYegGpMG
Try to specify your problem by creating one Minimum Verifiable Example and putting in question the code relevant to the problem
– Isac
I didn’t understand anything about your code or your problem, I just copied what you had into Pastebin here. I don’t understand your question or what you’re trying to do. But, it wouldn’t be the case to have a
return true;
at the end of its functioncalculo()
?– Victor Stafusa
This is a calculation system that after the check I pick up and send to another page and on this other page has a system for sending email. I put together the code logic of how it should work, but it doesn’t work
– Fernando
I’ll explain in parts, so that you understand better and can help me.
– Fernando
var limMetro2 = str.match([0-9]/",");
where does thisstr
? This regex is badly formatted need to/
at the beginning and end.– Sergio
Isn’t one missing
var formulario = document.getElementById("formulario");
at the beginning of the functioncalculo()
?– Victor Stafusa
The field Tipoobra it has some values pre defined that will be multiplied by the m2, thus generating a total, however it has some ifs, if ageThis is greater than 10 is added one more value and if the reinforced field is ticado It is like yes added another value, is all this is added in a total variable
– Fernando
m2 and ageTime has masks
– Fernando
I’m very lay in JS I’m still studying, this code copied in parts and tried to mount using logic, str < I don’t know what it means, now that spoke I’m playing on google for a search, let so var limMetro2 = match(/[0-9]/","/);
– Fernando
If I choose the option
Reforma Comercial - Casa
, it will take that text and multiply it by the square meter. It makes no sense to multiply a text by an area. How the type of work should be used in the calculation?– Victor Stafusa
I tried to assign values to the case case, but without success, I have to declare differently? remembering that my value can not pass numbers, because when arrive to send to the email would only arrive numbers and not text.
– Fernando
Yes it would not even make sense to multiply text, but I have to pass as value because of the time to send the email, I’m trying to attach value by the cases
– Fernando