ajax - get selected value from selectOnemenu using javascript in primefaces and open a dialog box -
how can selected value of primefaces <p:selectonemenu> using javascript/jquery?
i trying way, not go inside if condition, means id of element not correct.
<h:head> <script> function showdialog() { alert("insdie function"); if($('#someselect').val() == 'india') { dlg.show(); alert("after function"); } alert("outside function"); } </script> </h:head> <h:body> <h:form> <p:panel> <h:panelgrid columns="2"> <p:selectonemenu id="someselect" value="#{testcontroller.countryname}" <f:selectitem itemlabel="select one" itemvalue="" /> <f:selectitems value="#{addpatientprofilebb.patstatusselect}" itemlabel="#{testcontroller.countryname}" itemvalue="#{testcontroller.countrynameid}" /> <p:ajax process="someselect" update="dialog" oncomplete="showdialog()"/> </p:selectonemenu> </h:panelgrid> <p:dialog id="dialog" header="login" widgetvar="dlg"> <h:form> <h:panelgrid columns="2" cellpadding="5"> <h:outputlabel for="username" value="username:" /> <p:inputtext id="username" required="true" label="username" /> </h:panelgrid> </h:form> </p:dialog> </p:panel> </h:form> </h:body>
try changing
if($('#someselect').val() == 'india') { into
if($("select[name$='someselect_input'] option:selected").val() == 'india') { edit
you can improve selector changing
name$='someselect_input' into
name='yourformname\\:someselect_input'
Comments
Post a Comment