Javaika
Javaika Technologies:

Lightweight platform for web developers.

Skip the bloat, build on clean infrastructure.

Modular decentralised web frameworks.

JT - "Just Works"

User Guide - Web Interface

16. Dropdown Box

This guide demonstrates how to display a dropdown box, embedded within the window frame container. Resizing the window frame also resizes the dropdown box proportionately; clicking on a dropdown box item logs the event to the console.


                
               <!DOCTYPE html> <!-- Copyright (c) 2026 by Javaika Technologies -->

               <html lang = "en-AU"> <!-- Set the primary language to en-AU -->
    
                  <head>

                     <title>Dropdown Box</title> <!-- Set the page title -->
                     
                     <meta name = "robots" content = "noindex, follow">
  
                  </head>


                  <body>

                     <!-- Include the framework script tag -->
    
                     <script type = "module" src = "https://www.javaika.com/frame/web-interface@main/api.js"></script>
    
    
                     <!-- Run the demo as an ES Module -->

                     <script type = "module">
      
                        // Initialize a shorter prefix for referencing.

                        const jwi = window.javaika.webInterface;
                     
                     
                        let dropdownBoxControl; // Declare dropdown box control.
                     
                        let dropdownBoxItems = []; // Declare dropdown box items.
                     
                    
                        // Initialize the developer token endpoint.
            
                        jwi.init({
            
                           tokenEndpoint: "https://www.javaika.com/pscript/jwt-access.php"
            
                        });
            
            
                        // Authenticate before using the framework.
            
                        jwi.requestToken({
              
                           framework: "web_interface" // Specify the framework for token issuance.
              
                        });
                     
                     
                        // Authenticate callback handler.
                     
                        function onAuthenticate(event)
                        {
                           jwi.refreshToken(); // Refresh the authentication token.
              
                           console.log('[Web Interface] Authentication received callback:', event);
                        }
                     
                     
                        // Window frame resized callback handler.
                     
                        function onWindowFrameResized(event)
                        {
                           jwi.scaleInterfaceControls(event.detail.scaleFactor);
                        }
                     
                     
                        // Dropdown box initialized callback handler.
                     
                        function onDropdownBoxInitialized(event)
                        {
                           dropdownBoxControl.setSizeFactor(1.5); // Increase initial size.
                        
                           dropdownBoxControl.setText('Select Item');
                        
                        
                           // Add the dropdown box items to the dropdown box control.
                        
                           for (let dropdownBoxItem of dropdownBoxItems)
                           {
                              dropdownBoxControl.addItemEntry(dropdownBoxItem); // Add item.
                          
                              dropdownBoxItem.setEvent('click', onClick); // Bind click event.
                           }
                        
                           console.log('[Web Interface] Dropdown box initialized callback:', event);
                        }
                     
                     
                        // Click callback handler.
                     
                        function onClick(event)
                        {
                           const text = dropdownBoxControl.getText();
                        
                         
                           console.log('[Web Interface] Click callback:', event);
                        
                           console.log('[Web Interface] Dropdown box text:', text);
                        }
                     
                     
                        // Initialized callback handler.
                     
                        function onInitialized(event)
                        {
                           // Define the controls for the interface.
            
                           let windowFrame = new jwi.WindowFrame();
                        
                        
                           dropdownBoxItems[0] = new jwi.DropdownBoxItem('Item 1');
                        
                           dropdownBoxItems[1] = new jwi.DropdownBoxItem('Item 2');
                        
                           dropdownBoxItems[2] = new jwi.DropdownBoxItem('Item 3');
            
                        
                           dropdownBoxControl = new jwi.DropdownBox();
                        
                        
                           // Add initial styles for the dropdown box.
                        
                           dropdownBoxControl.addStyle('left', '29%');
                        
                           dropdownBoxControl.addStyle('top', '45%');
                        
                        
                           // Add dropdown box component to the window frame.
                        
                           windowFrame.addDropdownBoxElement(dropdownBoxControl);
                        
                        
                           // Enable manual resizing of the container window.
                        
                           jwi.setContainerManuallyResizable(true);
                        
                           jwi.setMaintainAspectRatio(true);
                        
                        
                           // Set handle offsets from the container window.
                        
                           jwi.setContainerOffsetHeight(50);
                        
                           jwi.setContainerOffsetWidth(50);
                        
                        
                           // Render interface to the browser window.
            
                           jwi.renderInterface(windowFrame);
                        
                        
                           console.log('[Web Interface] Framework initialized callback:', event);
                        }
                     
                     
                        // Callback event after authenticate.
            
                        document.addEventListener
                        (
                           'javaika.webInterface.authenticate', onAuthenticate
                        );
                     
                     
                        // Callback event after initialized.
            
                        document.addEventListener
                        (
                           'javaika.webInterface.initialized', onInitialized
                        );
                     
                     
                        // Callback event after dropdown box initialized.
            
                        document.addEventListener
                        (
                           'javaika.webInterface.dropdownBoxInitialized', onDropdownBoxInitialized
                        );
                     
                     
                        // Callback event after window frame resize.
            
                        document.addEventListener
                        (
                           'javaika.webInterface.windowFrameResized', onWindowFrameResized
                        );
    
                     </script>

                  </body>
  
               </html>

            

                
               /* Standard class styles */

               .javaika-dropdown-box
               {
                 position: absolute;
                 user-select: none;
              
                 width: 160px;
              
                 display: none;
               }
            
               .javaika-dropdown-box-thumb
               {
                 background: linear-gradient(to right, #E0E0E0, #E0E0E0, #E0E0E0);
               
                 box-shadow: 0 0 0 1px #E0E0E0 inset;
              
                 position: absolute;
                 cursor: pointer;
              
                 height: 40px;
                 width: 100%;
               }
            
               .javaika-dropdown-box-button
               {
                 background: linear-gradient(to bottom, #F0F0F0, #D0D0D0);
                
                 justify-content: space-between;
                 box-sizing: border-box;
              
                 border: 1px solid;
                 border-color: #AAA;
            
                 align-items: center;
                 cursor: pointer;
              
                 font-size: 14px;
                 padding: 8px;
              
                 display: flex;
                 height: 30px;
               }
            
               .javaika-dropdown-box-triangle
               {
                 border-right: solid transparent;
                 border-left: solid transparent;
                 border-top: solid black;
              
                 border-right-width: 10px;
                 border-left-width: 10px;
                 border-top-width: 10px;
               }
            
               .javaika-dropdown-box-track
               {
                 background-color: #F5F5F5;
                    
                 position: absolute;
                 display: none;
              
                 height: 100%;
                 width: 8px;
              
                 right: 0;
                 top: 0;
               }
            
               .javaika-dropdown-box-menu
               {
                 box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
                
                 box-sizing: border-box;
                 background-color: #FFF;
              
                 border: 1px solid;
                 border-color: #AAA;
              
                 transform: scale(0);
                        
                 position: absolute;
                 overflow: hidden;
              
                 font-size: 14px;
                 margin-top: 5px;
            
                 opacity: 0.2;
                 z-index: 1;
              
                 height: 100px;
                 width: 100%;
               }
            
               .javaika-dropdown-box-menu .javaika-dropdown-box-item
               {
                 justify-content: center;
                 align-items: center;
                 cursor: pointer;
              
                 padding: 0.6em;
                 display: flex;
               }
            
            
               /* Adjoined class styles */
            
               .javaika-dropdown-box.disabled
               {
                 pointer-events: none;
                 cursor: not-allowed;
              
                 opacity: 0.5;
               }
            
               .javaika-dropdown-box-menu.open 
               {
                 transform: scale(1);
              
                 opacity: 1;
               }
            
               .javaika-dropdown-box-menu .javaika-dropdown-box-item.active
               {
                 font-weight: bold;
               }
            
            
               /* Pseudo class styles */
            
               .javaika-dropdown-box-menu .javaika-dropdown-box-item:hover
               {
                 background-color: #F9F9F9;
               }
            
               .javaika-dropdown-box-button:hover
               {
                 background: linear-gradient(to bottom, #FAFAFA, #E0E0E0);
               }
            
               .javaika-dropdown-box-button:active
               {
                 background: linear-gradient(to bottom, #D0D0D0, #F0F0F0);
               }
            
               .javaika-dropdown-box:focus
               {
                 outline: none;
               }
            
               .javaika-dropdown-box:focus-visible
               {
                 outline: 2px solid #809DFF;
              
                 outline-offset: 3px;
               }

            
View Demo   Download Demo

Next capability: Demonstrate how to incorporate a Date Picker.