I'm trying to create Next/Prev button with selectOneMenu. Here is my code, please help me check it
<!-- Button arrow left -->
<p:commandButton id="prev" value="Prev" >
<p:ajax update="timesheetMonths" />
</p:commandButton>
<p:selectOneMenu height="450" id="month"
value="#{timeMonthView.month}"
style="width:150px;font-size:14px">
<p:ajax listener="#{timeMonthView.onMonthChange}"
update="timesheetMonths timesheetMonths1 year form" />
<f:selectItem itemLabel="#{bb.select}" itemValue="" />
<f:selectItems value="#{timeMonthView.months}" />
</p:selectOneMenu>
<c:if test="#{timeMonthView.month} eq null}">
<p:ajax listener="#{timeMonthView.onMonthChange}" update="timesheetMonths" />
</c:if>
<!-- Button arrow right -->
<p:commandButton
id="next" value="next" >
<p:ajax update="timesheetMonths" />
</p:commandButton>
AND
$("#next").click(function() {
var isLastElementSelected = $('#month> option:selected').index() == $('#month> option').length -1;
if (!isLastElementSelected) {
$('#month> option:selected').removeAttr('selected').next('option').attr('selected', 'selected'); } else {
$('#month> option:selected').removeAttr('selected');
$('#month> option').first().attr('selected', 'selected');
}
});
BUT i can't see it change. Please help me, thank a lots