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

203
Views
cant use first letter uppercase in value

i have a select where when i choose the option periodica a div change to display block, the problem is when i want to use the value "Periodica" with uppercase P the js just dont work anymore.

i know i can just send the value periodica but i need to store this value as Periodica

function showDiv(divId, element) {
  document.getElementById(divId).style.display = element.value == "periodica" ? 'block' : 'none';
}
#hidden_div {
  display: none;
}
<select required name="tdonacion" class="form-control form-group col-md-12" onchange="showDiv('hidden_div', this)">
  <option value="Puntual">Puntual</option>
  <option value="periodica">Periódica</option>
</select>

<div id="hidden_div">
  <select required name="dperiodica" class="form-control form-group col-md-12">
    <option value="Mensual">Mensual</option>
    <option value="Trimestral">Trimestral</option>
    <option value="Semestral">Semestral</option>
    <option value="Anual">Anual</option>
  </select>
</div>

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

Js is case sensitive. You can test element.value == "Periodica" or use toLowerCase()

if("periodica" == "Periodica"){
  console.log("Js isn't case sensitive")
}else{
  console.log("Js is case sensitive")
}
let text = "Periodica";
if(text.toLowerCase() == "periodica"){
  console.log("works")
}
console.log(text + " didn't change");

about 4 years ago · Santiago Gelvez Report

0

Try this:

JavaScript:

function showDiv(divId, element){
document.getElementById(divId).style.display = element.value == "Periodica" ? 'block' : 'none';}

HTML:

<select required name="tdonacion" class="form-control form-group col-md-12" onchange="showDiv('hidden_div', this)">
    <option value="Puntual">Puntual</option>
    <option value="Periodica">Periódica</option>
</select>
about 4 years ago · Santiago Gelvez Report

0

You can use toLocaleLowerCase() method.

my suggestion:

function showDiv(divId, element){
 document.getElementById(divId).style.display = element.value.toLocaleLowerCase() == "periodica" ? 'block' : 'none';}

hope it will work for you.

about 4 years ago · Santiago Gelvez 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!