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

154
Views
Multiple buttons with different ID's to one Variable

So im trying to make different languages for a user terminal. The way you select one is by clicking on an image with the corresponding country flag, which changes the language to the national language of the country. My thoughts on how to do that would be that upon click, the button would change the value of a variable which in change would alter the displayed language. My first thought on how to implement that would be with switch case, but i really just dont know how to program it.

This is what i got so far, but when i tried it with alert, it didnt work:

var languages = "";
        $('#UK, #FR, #SP, #HU, #IN, #CH, #JA, #SK, #BU').click(function() {
            switch(languages){
                case "#UK":languages = 'UK';break;
                case "FR":languages = 'FR';break;
                case "SP":languages = 'SP';break;
                case "HU":languages = 'HU';break;
                case "IN":languages = 'IN';break;
                case "CH":languages = 'CH';break;
                case "JA":languages = 'JP';break;
                case "SK":languages = 'SK';break;
                case "BU":languages = 'BU';break;
            }
        })

I, in theory could also just make the same followup page 10x and let the buttons load those pages, but i wouldnt be satisfied with that. Also im sorry if this is a stupid question, im still very new to js.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The id of your clicked element seems to exactly match the language you want to set, so simply do that.

let languages = "";
        
$('#UK, #FR, #SP, #HU, #IN, #CH, #JA, #SK, #BU').on('click', function() {
    languages = this.id;
})
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!