How to get

value using JQuery

后端 未结 2 433
不思量自难忘°
不思量自难忘° 2021-01-12 20:00

How I can get select component value using Jquery or javascript

MyJSF code below


      

        
相关标签:
2条回答
  • 2021-01-12 20:08

    you can pass the this in this function:

    onchange="onCall(this)"
    

    and i am assuming you have defined this onCall function in the global scope, then you can do this:

    onCall(el){
        alert(el.value);
    }
    
    0 讨论(0)
  • 2021-01-12 20:12

    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
    
    0 讨论(0)
提交回复
热议问题