?
Solved

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

Posted on 2004-08-17
3
Medium Priority
?
356 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 200 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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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