Form drop down menu scrollbars

Posted on 2008-11-19
Last Modified: 2012-05-05
I have a drop down menu created by a loop with java. For some reason I cannot get it to add scrollbars to the drop down menu.

Here is my code:


                height: 30px;

                max-height: 30px;

                overflow: scroll;





                filter: alpha(opacity=70);


<table cellpadding="0" cellspacing="0" border="0">


                                <td onmouseover="showmenu()" onmouseout="hidemenu()">


                                <input value="<%= ResponseBean.getDynamicPagesMainLinks1(0) %>" type="hidden" class="styled" id="MenuSelected_InputText" name="<%= com.servlets.DynamicPagesEditExecuteServlet.HTTP_REQUEST_FIELD_KEY_MAIN_LINKS_1 %>" onchange="setformsubmitMarker(this.form,"selectmenu");this.form.submit();">

                                <span class="nav1" id="MenuSelected_Text"><%= ResponseBean.getDynamicPagesMainLinks1(0) %></span><br />

                                <table class="menu" id="LinkChange">

                                                 <tr><td class="menu">To change this link, pick from the following pages.</td></tr>


                                         for (int i=0; i<ResponseBean.getSizeOfDynamicLayouts(); i++)



                                                 <tr><td class="menu"><a href="javascript:MenuSelect('<%= ResponseBean.getDynamicLayoutsLinkName(i) %>')"><%= ResponseBean.getDynamicLayoutsLinkName(i) %></a></td></tr>


                                   <% } %>

                                                 <tr><td class="menu"><a href="../m1_dynamic_link_add.jsp">Add a link</a></td></tr>





Open in new window

Question by:the_hero
    LVL 1

    Expert Comment

    I don't know Java so I could be totally wrong here but have you tried using a form element for a dropdown list instead of table rows?

    For example:

    <select name="menu" size="1">
        //start your loop here
        <option value="value">label</option>
        //end your loop here

    and replace the value and label with your dynamic ones
    LVL 16

    Accepted Solution

    I got your code to work by changing the table to a div, removing the max-height declaration in the CSS, plus a bunch of other stuff. Works in IE7 and FF3.
    Compare your code to my code carefully. I removed the ASP stuff, for testing purposes in HTML/JavaScript/CSS only.

    		height: 34px;
          overflow: -moz-scrollbars-vertical;
    		overflow-y: scroll;
    		background: gray;
    		filter: alpha(opacity=70);
       function showmenu()
          document.getElementById("LinkChange").style.visibility = "visible";
       function hidemenu()
          document.getElementById("LinkChange").style.visibility = "hidden";
       <table cellpadding="0" cellspacing="0" border="0">
    				<td onmouseover="showmenu()" onmouseout="hidemenu()">
    	   			<input value="ResponseBean.getDynamicPagesMainLinks1(0)" type="hidden" class="styled" id="MenuSelected_InputText" name="HTTP_REQUEST_FIELD_KEY_MAIN_LINKS_1" onchange="setformsubmitMarker(this.form,'selectmenu');this.form.submit();">
    				<span class="nav1" id="MenuSelected_Text">ResponseBean.getDynamicPagesMainLinks1(0)</span><br />
                <div class="menu" id="LinkChange">
                    <div><span class="menu">To change this link, pick from the following pages.</span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name1')">Name1</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name2')">Name2</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name3')">Name3</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name4')">Name4</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name5')">Name5</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name6')">Name6</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name7')">Name7</a></span></div>
                    <div><span class="menu"><a href="javascript:MenuSelect('Name8')">Name8</a></span></div>
                    <div><span class="menu"><a href="../m1_dynamic_link_add.jsp">Add&nbsp;a&nbsp;link</a></span></div>

    Open in new window


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now