You did not report anything about the HTML representation of createEvent:EventSeatingPlan_input , while it is mandatory for us (and you!) To know how to enable JS interception. You also did not say whether you are using <h:selectOneMenu> or <p:selectOneMenu> , so we cannot look into the generated HTML view. The former generates a <select><option> , and the latter generates a <div><ul><li> , which interacts with a hidden <select><option> . Both representations of dropdown menus require a different approach in JS. In addition, information about how you register the change event handler function is required. Is this by binding the onchange attribute or by nesting a <f:ajax> or <p:ajax> ?
In any case, based on the information provided, I’ll guess that you have
<h:selectOneMenu ...> <f:ajax render="dataTableId" /> </h:selectOneMenu>
which will generate a <select onchange="..."><option> .
According to your first attempt:
function fireChange() { var element = document.getElementById("createEvent:EventSeatingPlan_input"); element.change(); }
This will not work on <h:selectOneMenu> , because the HTMLSelectElement interface does not have a change property or method. Instead, this onchange property returns an event handler that can be called directly by adding () .
In <h:selectOneMenu> following will work:
function fireChange() { var element = document.getElementById("createEvent:EventSeatingPlan_input"); element.onchange(); }
However, this in turn will fail in <p:selectOneMenu> because it returns an HTMLDivElement instead of an HTMLSelectElement . HTMLDivElement does not have an onchange property that returns an event handler. As said, <p:selectOneMenu> creates a <div><ul><li> widget that interacts with a hidden <select><option> . You must register this widget in a JS context and then use its special triggerChange() method.
So, given
<p:selectOneMenu widgetVar="w_menu" ...> <p:ajax update="dateTableId" /> </p:selectOneMenu>
it should do
function fireChange() { w_menu.triggerChange(); }