如何使用 Jquery 或 javascript 获取选择组件值
下面是 MyJSF 代码
<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>
请帮我解决这个问题
最佳答案
由于 Primefaces 为其组件提供了 Javascript API,您可以通过 widgetVar
访问它
xhtml
<p:selectOneMenu widgetVar="selectWV">
</p:selectOneMenu>
JS
PF('selectWV').getSelectedValue();//gets the value
PF('selectWV').getSelectedLabel();//gets the label
关于jquery - 如何获取<p :selectOneMenu> value using JQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21310251/