Style Sheets
  Home arrow Style Sheets arrow Page 2 - A More Complex Way of Building Replacement...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

A More Complex Way of Building Replacement Combo Boxes
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-04-10

    Table of Contents:
  • A More Complex Way of Building Replacement Combo Boxes
  • Increasing our Options
  • Data Storage Format
  • Extracting the Data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A More Complex Way of Building Replacement Combo Boxes - Increasing our Options


    (Page 2 of 4 )

    In this example, there are just ten options, and it is easy enough to include them directly in the page while still being entirely visible, even on displays with low resolution. Many more options, though, and the options div would become taller than the display. One thing we can do is break the combo div down into smaller divs, and allow the user to access them as necessary. Add the code in bold below to the replacementcombos.html file:

    <div id="combodiv">
     
    <a class="option" href="#" onclick="setOption(this)">Option 1</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 2</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 3</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 4</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 5</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 6</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 7</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 8</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 9</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 10</a>
     
    <a class="option" href="#" onclick="openNextPage()">more options -></a>
    </div>
    <div id="combodiv2">
     
    <a class="option" href="#" onclick="setOption(this)">Option 11</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 12</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 13</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 14</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 15</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 16</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 17</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 18</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 19</a>
     
    <a class="option" href="#" onclick="setOption(this)">Option 20</a>
    </div>

    So now we have two combo divs and an extra a element at the bottom of the first div. We'll need some additional CSS for the second div, and I've adjusted each div so that it is big enough to hold all 11 options without a scroll bar. Alter the combo.css file so that the selectors that match the option divs are as follows. I've highlighted the changes in bold to make them obvious:

    #combodiv {
      
    padding:0px;
       
    display:none;
      
    position:relative;
      
    left:151px;
      
    height:200px;
      
    width:120px;
      
    border-style:solid;
      
    border-width:0px 1px 1px 1px;
      
    border-color:blue;
      
    background-color:white;
    }

    #combodiv2 {
      
    padding:0px;
      
    display:none;
      
    position:relative;
      
    top:-201px;
      
    left:272px;
      
    height:200px;
      
    width:120px;
      
    border-style:solid;
      
    border-width:1px 1px 1px 1px;
      
    border-color:blue;
      
    background-color:white;
    }

    Finally, the combo.js file will need an extra line of code in the setOption() function to close both option divs, as well as a new function to handle a click on the more options > option:

    function setOption(element) {
      
    var selection = element.childNodes[0].nodeValue;
      
    var combo = document.getElementById('combofield').value = selection;
      
    document.getElementById('combodiv').style.display = "none";
      
    document.getElementById('combodiv2').style.display = "none";
      
    comboopenflag = "off";
    }

    function openNextPage() {
      
    document.getElementById('combodiv2').style.display = "block";
    }

    More Style Sheets Articles
    More By Dan Wellman


       · In the first of these two articles, we looked at a quick and easy way of replacing...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek