Solved

How to display a combox if a parameter is set else display another combox-box?

Posted on 2004-08-17
3
348 Views
Last Modified: 2010-04-01
I have a JSP page and I want to display either one combo-box
if no parameter is set and display a combo-box  with some data

example of the url - http://test/Pager

else

if a parameter is set  : groupname=gr-software is set  - then display another combox with some other data

example of the url - http://test/Pager?groupname=gr-software

Here is the JSP Code sample  and the
NO PARAMETERS ----CODE IS COMMENTED


<%-------NO PARAMETERS-------%>
<%--
 
    CrewingInterface x_crewing = (CrewingInterface) getServletContext ().getAttribute ( "CrewingManager" );
    List             v_members = x_crewing.getMembersWithTextPager ( );

    pageContext.setAttribute ( "v_members", v_members );

--%>
<%--
<select name = "To" size ="15"> <option value="None" selected></option>
--%>
<%-- Get the column names for the header of the table --%>
<%--
    for ( int lcv = 0; lcv < v_members.size(); lcv++ ) {
    String s_member = (String) v_members.get ( lcv );
        try {
            PhoneDirectoryManager x_manager = (PhoneDirectoryManager) FilmDensitySharedResources.getResource ( "PhoneDirectoryManager" );

            PhoneDirectory x_phone = x_manager.getPhoneDirectoryFromEmail ( s_member );

            out.println ("<option value=\"" +s_member +"\">"+x_phone.getFirstName()+" "+ x_phone.getLastName()+"</option> ");


    } catch ( Exception e ) {}  //  end catch
    }  // end  for loop

--%>

<%----- WITH PARAMETER groupname = gr-software ----%>
<%
 String s_groupname =  request.getParameter ( "groupname" );

 if ( (null == s_groupname) || (s_groupname.length () < 1) ) {
        s_groupname = "gr-software";
 }
 CrewingInterface x_crewing_pager = (CrewingInterface) getServletContext ().getAttribute ( "CrewingManager" );
    List             v_members_pager = x_crewing_pager.getActiveMembersInGroupWithTextPager ( s_groupname );
    String           s_parent = x_crewing_pager.getParentGroup ( s_groupname );

  pageContext.setAttribute ( "v_members_pager", v_members_pager );
  pageContext.setAttribute ( "s_parent", s_parent );

%>

<select name = "To" size ="15"> <option value="None" selected></option>
<%-- Get the column names for the header of the table --%>
<%
    for ( int lcv = 0; lcv < v_members_pager.size(); lcv++ ) {
    String s_member_pager = (String) v_members_pager.get ( lcv );
        try {
            PhoneDirectoryManager x_manager = (PhoneDirectoryManager) FilmDensitySharedResources.getResource ( "PhoneDirectoryManager" );

            PhoneDirectory x_phone = x_manager.getPhoneDirectoryFromEmail ( s_member_pager );

            out.println ("<option value=\"" +s_member_pager +"\">"+x_phone.getFirstName()+" "+ x_phone.getLastName()+"</option> ");


    } catch ( Exception e ) {}  //  end catch
    }  // end  for loop

%>


Please advise
0
Comment
Question by:sdesar
3 Comments
 

Expert Comment

by:aniket_pcs
ID: 11853210
Not sure if I understood your question correctly.

Can you do with HTML div tag? Two layers, each having a combo box.
Populate both the combo-boxes initially and keep the second one hidden. Once you select value in the first combo box, make the second layer visible?
0
 
LVL 2

Accepted Solution

by:
jjerome00 earned 50 total points
ID: 11855132


If I understand this correctly, you only want to show the 2nd combo box if 1 particular item is selected in the first combo box.

I've done this before using a combination of javascript and CSS:

<head>
<script language="javascript">
<!--
            function hide_showCR()  
            {
                  if (document.testform.item[0].selected)
                  {  
                              document.testform.hiddenitem.style.display = 'none';
                              document.testform.hiddenitem.disabled = true;
                  } else {
                              document.testform.hiddenitem.style.display = '';
                              document.testform.hiddenitem.disabled = false;
                  }
            }
-->
</script>

</head>
<body>

<form method="Post" action="" name="testform" id="testform">

<table cellspacing="0" cellpadding="0" border="0" width="200px">
<tr>
      <td width="100px">
            <select name="item" id="item">
            <option value="1" onclick="hide_showCR()">hide
            <option value="2" onclick="hide_showCR()">show
            </select>
      </td>
      <td width="100px">
            <select name="hiddenitem" id="hiddenitem">
            <option value="1">item1
            <option value="2">item2
            </select>                        
      </td>
</tr>
</table>
</form>

<script language="javascript">
<!--
      hide_showCR();
//-->
</script>

</body>
0
 

Author Comment

by:sdesar
ID: 11872412
Thanks for all the comments -
I need the following if the user enters this


example of the url - http://test/Pager.jsp?value=0  ---- with a value=0 parameter  then display one type of combo box

else

if a parameter is set  : groupname=gr-software is set  - then display another combox with some other data

example of the url - http://test/Pager.jsp?value=1&groupname=gr-software  - with a value = 1 parameter


ITS not based on what the user selects in a particular combo-box, its based on a parameter that is entered in the URL

Please advise

awaiting a resposne

Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 36
How to group array of objects ? 5 60
dynamic reloading of jsp in jetty 2 118
thymeleaf natural templating vs JSP 2 65
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now