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

94
Views
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 answers
Answer question

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 Report

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 Report

0

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