Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
Call one set of JS code instead of another

I have a RF to L-band calculator/converter that I am designing and developing for my FT job. Now C-Band was easy as we only use one frequency range. KU band we have 2 frequency ranges. So for that calculator I want to use Radio Buttons. When an engineer Checks Radio 1 they use the functions coded for that Freqeuncy Range, if they Check Radio 2, they use the functions coded for that frequency range.

What can I do to call this when the radio is .checked?

Should I create an array of variables that assign functions to? I'm pretty new to JS. So let me know if I am not clear. TIA.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

NVM. I think I figured out a work around.

I will use "If a is check var b = freqOne else b = freqTwo".

about 4 years ago · Juan Pablo Isaza Relatório

0

You can match function names to radio button values

function foo() {
    console.log("foo was called");
}

function bar() {
    console.log("bar was called");
}

function loremipsum() {
    console.log("loremipsum was called")
}

function test(item) {
    window[item.value]();
}
<label>Foo <input type="radio" name="something" value="foo" onclick="test(this)"></label>
<label>Bar <input type="radio" name="something" value="bar" onclick="test(this)"></label>
<label>Lorem <input type="radio" name="something" value="loremipsum" onclick="test(this)"></label>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda