I am trying to save the value of selected item from p:selectOneListbox on a button click using jquery.
Tried to replicate but it didn't work for me : How to get the value of <p:selectOneMenu> in jquery?
<p:selectManyMenu id="advanced1" widgetVar='commmentWidget'
value="#{decisionTreeBean.option1}" showCheckbox="true" styleClass="XXXX">
<f:selectItems value="#{decisionTreeBean.XXXX}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectManyMenu>
Below jquery didn't work (name attribute is the name from the generated HTML)
jQuery(".generateBtn").on("click",function(event){
var $element = jQuery("select[name='A3128:searchForm:basic1_input']option:selected").val();
alert($element);
});
How do I store the text value of the item selected from selectOneListbox into a variable.