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

163
Views
I cant get the value from selected option, what is wrong with these?
<select id="region_id" onChange="get_region_id()" class="form-control">
  <option disabled selected>--Choose Region--</option>

  <?php foreach($region as $row){?>
  <option value="<?php  $row['region_c'];?>">
    <?php echo $row['region_m'];?>
  </option>
  <?php }?>

</select>
<?php ?> -----------------------

<script type="text/javascript">
  function get_region_id() {

    var select = document.getElementById('region_id');
    var options = select.options[select.selectedIndex].value;

    alert(options);
  }
  get_region_id();
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add the function to an onChange event, so it triggers every time a new value is selected:

var select = document.getElementById('region_id');

function get_region_id() {
  var options = select.options[select.selectedIndex].value;
  alert(options);
}

select.addEventListener('onChange',get_region_id)
<select id="region_id" onChange="get_region_id()" class="form-control">
  <option disabled selected>--Choose Region--</option>
  <option value="one">one</option>
  <option value="two">two</option>
  <option value="three">three</option>
  <option value="four">four</option>
</select>

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!