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

120
Views
set values using switch case in JS

I am trying to get the value of an element by class so i could use a switch case to change different element`s values in a table. I seems like the switch case doesn't get the value or i am not using it correctly.

Html code-

<input type="radio" name="Button" class="ButtonState" checked id="Button1" value="1" onclick="setStat1()"/>
<label class="Button" for="Button1">Vagabond</label>
<input type="radio" name="Button" class="ButtonState" id="Button2" value="2" onclick="setStat1()" />
<label class="Button" for="Button2">Warrior</label>

JS-

function setStat1() {
switch (document.getElementsByClassName("ButtonState").value) {
    case 1:
        document.getElementById("vigor").innerHTML = vig;
        document.getElementById("mind").innerHTML = mind;
        document.getElementById("end").innerHTML = end;
        document.getElementById("str").innerHTML = str;
        document.getElementById("dex").innerHTML = dex;
        document.getElementById("int").innerHTML = int;
        document.getElementById("faith").innerHTML = faith;
        document.getElementById("arcane").innerHTML = arcane;
      break;
}
}
about 4 years ago · Juan Pablo Isaza
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!