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

171
Views
Set select value with Javascipt

I Want to set the selected value of a html select with the help of javascript. This is my current js code:

var g = document.getElementById('g');
g.value = '1';

While this is my select:

   <select id="g">
    <option value="" disabled selected>  Geschlecht...</option>
    <option value="1" id="M">Männlich</option>
    <option value="2" id="F">Weiblich</option>
  </select>

However this doesn't seem to work as i get the following error:

Uncaught TypeError: Cannot set properties of null (setting 'value')

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!