JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
871 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi friends,
I have the following problem. I have 8 selects within a div, where each select has two values: 0 and 1. When I click for the first time on any select to select 0 or 1, when I click on the select arrow, it already considers that I selected 0. From then on, when clicking on the arrow for other selects, the functionality is normal. Only the first time, it behaves differently. Follow the code.
Tks
const divElementos = document.getElementById('custom-select');
const selectElementos = divElementos.querySelectorAll('select');
// cliue nos selects
divElementos.addEventListener('click', function()
{
selectElementos.forEach(select =>
{
binaryCode = '';
total = 0;
let t;
let cont = 0;
// varre todos os selects
selectElementos.forEach(select =>
{
valorSelecionado = obterValorSelecionado(select);
idDoSelect = select.options[select.selectedIndex].value;
if(idDoSelect == 1)
{
var t = binaryValues[cont];
total = total + t;
}
binaryCode += valorSelecionado;
document.getElementById('txt1').textContent = total + " em binário é: " + binaryCode;
cont++;
});
});
if (total == numsorteado)
{
// Mostra o botão com ID "jogardenovo"
botao.style.display = 'inline';
document.getElementById('msg').textContent = "Correto! Muito bem.";
}
});