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

240
Views
HTML option value post over Boolean instead of String

I have a simple HTML select dropwdown in which the user can change between the following values

<select id="changeIsActive">
    <option value = true>Active</option>
    <option value = false>Inactive</option>
    <option>All</option>
</select>

I then have an event that binds to ^ that "converts" the String values into actual Booleans. And the Booleans then get passed to a Mongo Query Object for the Server to filter on.

'change #changeIsActive'(e, template) {           
          let retVal;
          switch (e.target.value) {
            case "true":
                retVal = true;
                break;
            case "false":
                retVal = false;
                break;
            case "All":
                retVal = null;
            default:
                break;
        }
    }

Is there a better way of converting the String literal of "true" and "false" to their Boolean values? Thanks

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

0

'change #changeIsActive'(e, template) {           
const obj = {
    'true':true,
    'false':false,
    'All':null
}

const retVal  = obj[e.target.value] 
}
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!