Solved

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

Posted on 2004-08-17
3
353 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
spring AOP 6 91
sortaSum challenge java 17 174
listing all functions in JavaScript 19 232
going to wrong jsp page 2 50
Original post  on Monitis Blog. Web performance monitoring is broken into two camps: passive and active. Passive monitoring is defined as looking at real-world historical performance by monitoring actual log-ins, site hits, clicks, requests for…
We have put together a white paper that aims to explain how MSPs can both improve their offering and ease the pain of after-hours service by: -Suggesting changes to workflow -Indicating how to rework policy to suit your team -Providing ConnectW…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

697 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