Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda