Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6956189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:50:08+00:00 2026-05-27T14:50:08+00:00

I am having a drop down menu, on selecting a particular value from a

  • 0

I am having a drop down menu, on selecting a particular value from a drop down menu, i have to show a datatable corresponding to it and on selecting second from drop down menu ,value the previous data table should hide and the datatable corresponding to second value should populate and so on
here are my codes:

   <h:selectOneMenu value="#{bean.value}"
styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all"
style="width:100px;">
<f:selectItem itemLabel="Select" itemValue="Select" />
<f:selectItem itemLabel="5" itemValue="5" id="mySelectedValue1" onclick="hideOrShow(??);"/>
<f:selectItem itemLabel="6" itemValue="6" id="mySelectedValue2" onclick="hideOrShow(??);"/>
<f:selectItem itemLabel="7" itemValue="7" id="mySelectedValue3" onclick="hideOrShow(??);"/>    
    </h:selectOneMenu> 


<script type="text/javascript">   
function hideOrShow(show) {
var obj = document.getElementById("myForm:myPanel");
     if (show) { 
        obj.style.display = "block";
     }
 else {
         obj.style.display = "none"; 
    } 
  } </script> 


<h:panelGrid id="myPanel" columns="2"> 
    ... 
</h:panelGrid> 

My Question is what to put as parameters in HideOrShow() shown as ?? so that java script function will identify it. And how initially all the datatables will be hidden?

thanks: curious

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:50:09+00:00Added an answer on May 27, 2026 at 2:50 pm

    Using plain JS in combination with JSF is often recipe for trouble and unintuitiveness because of the way how JSF state management works. You should prefer solving the problem using pure JSF. It will also often end up in a simpler view. You can use the JSF-provided <f:ajax> for this particular purpose in combination with the rendered attribute on the components to show/hide.

    Kickoff example:

    <h:form>
        <h:selectOneMenu value="#{bean.value}">
            <f:selectItem itemLabel="Select" itemValue="#{null}" />
            <f:selectItem itemLabel="5" itemValue="5" />
            <f:selectItem itemLabel="6" itemValue="6" />
            <f:selectItem itemLabel="7" itemValue="7" />
            <f:ajax render="tables" />
        </h:selectOneMenu> 
    
        <h:panelGroup id="tables">
            <h:dataTable value="#{bean.list5}" rendered="#{bean.value == 5}">
                ...
            </h:dataTable>
            <h:dataTable value="#{bean.list6}" rendered="#{bean.value == 6}">
                ...
            </h:dataTable>
            <h:dataTable value="#{bean.list7}" rendered="#{bean.value == 7}">
                ...
            </h:dataTable>
        </h:panelGroup>
    </h:form>
    

    Make sure that the bean is in the view scope whenever the tables contain by itself input components.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have built jQuery drop-down menu which is having problems floating over the UI
I want to have a drop down menu where a user can select from
We have all seen countless instances of forms with a select drop down having
I am having a page with a drop down menu and images blocks beneath
I'm having some trouble getting my drop down menu to work. When you rollover
I'm having a weird problem with my CSS drop down menu. It shows up,
Im having an issue with a drop down menu in IE only and Im
I am trying to create a drop-down-menu and i am having some problems with
I'm having difficulties with an MFC application menu drop down. I want the drop
I'm having issues with my drop down menu on i.e 6/7 where it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.