0
My code is working in Chrome, but in Safari it doesn’t go through any if else
and goes straight to the else
.
//FUNÇÃO PARA ATIVAR NA SELEÇÃO DOS DROPBOX
var selecao= document.querySelectorAll('.validation-lenient');
function handleClick (event)
{
//IDENTIFICAÇÃO DO CAMPO SOMA PELO ID DO FORMULARIO HTML
var soma = document.getElementById('campo-soma').innerText;
//PREENCIMENTO DO CAMPO SOMA
var camposoma = document.querySelector('[name="field46[]"]').value = soma;
//VARIAVEL IF PARA PREÇO COM BASE NAS SOMAS DOS PESOS ANTERIORES
if (camposoma == "2 2 50 Almoço") {
nomefesta = "Festa VIP";
nomefesta2 = "Festa TOP";
tabelaprazo = "TABELA | PRAZO(10%) | AVISTA (15%)";
precoVip = " valor | valor | valor";
precoTop = " valor | valor | valor";
}
else if (camposoma == "2 2 60 Almoço") {
nomefesta = "Festa VIP";
nomefesta2 = "Festa TOP";
tabelaprazo = "TABELA | PRAZO(10%) | AVISTA (15%)";
precoVip = " valor | valor | valor";
precoTop = " valor | valor | valor";
}
else {
precoVip = "não se aplica";
precoTop = "não se aplica";
}
//PREENCIMENTO DO CAMPO ORÇAMENTO
var campoorcamento = document.querySelector('[name="field51[]"]').value = precoVip;
var campoorcamento = document.querySelector('[name="field52[]"]').value = precoTop;
var campoorcamento = document.querySelector('[name="field58[]"]').value = nomefesta;
var campoorcamento = document.querySelector('[name="field63[]"]').value = nomefesta2;
}
//FIM DA FUNÇÃO DOS DOS DROPBOX
selecao.forEach(function(item){
item.addEventListener('click', handleClick, {once: false});
});
I believe that is not the problem, after all, it defines the value of
soma
fordocument.getElementById('campo-soma').innerText
, however, I think the problem is to get the value withinnerText
, there is a post with this same problem.– Vinicius Lourenço
The problem is in the variable
camposoma
, and not on the variablesoma
.– Sam
Yes, but she’s assigned with
var camposoma = document.querySelector('[name="field46[]"]').value = soma;
, first it assigns the variable valuesoma
to the element he has just sought byquerySelector
, and after that, assign in the variablecamposoma
, at the end, the value ofcamposoma
is equal to that of thesoma
.– Vinicius Lourenço
I understood, but I didn’t see anything abnormal in it. The only problem I noticed in the code was what I described in the answer.
– Sam
Ah tah. Actually innerText may not be compatible with Safari. I’ll add in the reply. Thanks!
– Sam