Solved

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

Posted on 2004-08-17
3
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The conference as a whole was very interesting, although if one has to make a choice between this one and some others, you may want to check out the others.  This conference is aimed mainly at government agencies.  So it addresses the various compli…
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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