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

96
Vistas
Selected option returning tag not textual value

I have this bootstrap select element

   <select id="createAxiomSelect" class="form-select">
      <option selected vale="true">True</option>
       <option value="false">False</option>
    </select>

I am trying to get 'true' or 'false' when selected. Instead I am getting the tag "<option selected="" vale="true">True</option>"

I have tried many different ways to do this. eg:

  1. $("#createAxiomSelect").find("option:selected").text()
  2. $("createAxiomSelect").val()
  3. $("#createAxiomSelect option:selected").text()
  4. document.getElementById("createAxiomSelect").innerHTML

These all return "<option selected="" vale="true">True</option>"

Can someone please find where I am going wrong, thank you

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Assuming you are using jQuery since it does state that in the question: Item #2 is close. The correct syntax would be:

$("#createAxiomSelect").val();

See first the jQuery id selector requires '#'. .val() will simply return the value of the selected option.

Note, you have a spelling error in your first option vale= rather than value=. This will return instead the text of the option thus 'True' rather than 'true'.

Otherwise, I think you are on the right track. You can also do this using straight JavaScript, but since you are using jQuery, I'd suggest staying with that pattern and not mix and match.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use document.forms['<formName>'].elements['<selectName>'].value.
Important: you should use name attribute, not id.

about 4 years ago · Juan Pablo Isaza Denunciar

0

$("#createAxiomSelect option:checked").value
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