Reputation: 453
I want to get the selected index for my h:selectOneMenu field.
I can either use javascript or jquery
please help
<h:selectOneMenu id="myId" value="#{AddScriptBean.scriptEngine}" >
<f:selectItems value="#{AddScriptBean.scriptEngines}"/>
</h:selectOneMenu>
Upvotes: 2
Views: 2180
Reputation: 123739
Assuming your selectOneMenu is rendered as select
.
With jquery you can use this to get the selected index.
$(function(){
$('#myId').prop('selectedIndex')
});
With javascript it would be
document.getElementById('myId').selectedIndex
Upvotes: 1