Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!