如何使用javascript显示/隐藏JSF面板组?

如何使用javascript显示/隐藏JSF面板组?,javascript,jsp,jsf,alfresco,Javascript,Jsp,Jsf,Alfresco,我想根据SelectOne菜单中选择的选项显示/隐藏面板组 这是我的代码: new.jsp <h:form id="formPregunta"> <h:outputText value="Selecciona un tipo de pregunta"/> <h:selectOneMenu onchange="tipoSeleccionadoOnChange(this)" id="tipoSeleccio

我想根据SelectOne菜单中选择的选项显示/隐藏面板组

这是我的代码:

new.jsp

        <h:form id="formPregunta">
            <h:outputText value="Selecciona un tipo de pregunta"/>
            <h:selectOneMenu onchange="tipoSeleccionadoOnChange(this)" id="tipoSeleccionado" value="#{seleccionaTipoPreguntaBean.tipos}">
                <f:selectItems value="#{seleccionaTipoPreguntaBean.tiposValue}" />
            </h:selectOneMenu>
            <br />

            <h:panelGroup id="prueba" style="display: none">
                <h:outputText value="Enunciado "/>
                <h:inputText value=""/><br />
                <h:outputText  value="Sentencias"/>
                <h:inputText value=""/>
                <h:commandButton value=""/>
            </h:panelGroup>

        </h:form>

使用
h:panelGroup中的
rendered
属性

尝试使用document.getElementById(“prueba”).style.display=“block”;在你的情况下。。或者在这里添加html代码而不是js代码?我只能使用javascript,不能使用ajax:(搜索show/hide the div(或span)。这个网站上有很多问题/答案。
function tipoSeleccionadoOnChange(sel) {
      if (sel.value=="2"){
           divC = document.getElementById("prueba");
           divC.style.display = "";


      }else{

           divC = document.getElementById("prueba");
           divC.style.display="none";

      }
}