I have this bootstrap select element
<select id="createAxiomSelect" >
<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:
$("#createAxiomSelect").find("option:selected").text()
$("createAxiomSelect").val()
$("#createAxiomSelect option:selected").text()
document.getElementById("createAxiomSelect").innerHTML
These all return "<option selected="" vale="true">True</option>"
Can someone please find where I am going wrong, thank you
CodePudding user response:
You can use document.forms['<formName>'].elements['<selectName>'].value
.
Important: you should use name
attribute, not id
.
CodePudding user response:
$("#createAxiomSelect option:checked").value