Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

12 Experts available now in Live!

Get 1:1 Help Now