Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda