How I can get select component value using Jquery or javascript
MyJSF code below
<h:form>
<p:selectOneMenu style="width:150px" id="id" onchange="onCall()">
<f:selectItem itemLabel="Select" itemValue=""></f:selectItem>
<f:selectItem itemLabel="Other" itemValue="Other"></f:selectItem>
</p:selectOneMenu>
<p:selectBooleanCheckbox id="flag"/>
<p:inputText id="name" value="#{mybean.value}/>
</h:form>
Please help me to solve this issue
As Primefaces provides a Javascript API for its components, you can access it through the widgetVar
xhtml
<p:selectOneMenu widgetVar="selectWV">
</p:selectOneMenu>
JS
PF('selectWV').getSelectedValue();//gets the value
PF('selectWV').getSelectedLabel();//gets the label
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With