cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="container">
  <h4>ComboBox</h4>
  <div class="combobox">
  <input type="text" placeholder="Combobox"/>
  <ul>
    <li><p>Donec sed condimentum</p><p>sapien. In ligula</p><p> augue; ultrices sit amet</p></li>
    <li><p>2 Akepiro street</p>
      <p>Mt. Eden</p>
    <p>Auckland - 1024<p>
    </li>
     <li>Strawberry</li>
     <li>Cherry</li>
     <li>Rasberry</li>
  </ul>
</div>
<div class="combobox">
  <input type="text" placeholder="Combobox"/>
  <ul>
    <li>Tiger</li>
     <li>Cheetha</li>
     <li>Lion</li>
     <li>Cat</li>
     <li>Dog</li>
  </ul>
</div>
</div>
            
          
!
            
              @import "compass/css3";

html,body{margin:0;padding:0;background:#eee;font-family:arial;
color:#333}

.container{
width:200px;
  margin:auto;
  padding:25px;
}

.combobox{
position:relative;
  margin-bottom:30px;
  input{padding:5px;
  width:200px;
  border-radius:5px;
  border:1px solid #00B0F2;}
  ul{
  position:absolute;
    background:#fff;
    width:100%;
    border-radius:5px;
    margin:0;
    padding:0;
    display:none;
    border:1px solid #ccc;
    z-index:2;
      li{padding:3px 10px;
    display:block;
    cursor:pointer; 
      border-bottom:1px solid #ccc;
      p{font-size:12px} &:hover{background:lighten(#00B0F2,15%)}}
  }
}
            
          
!
            
              /*****jquery combobox sample******
******Amit Ashok Kamble**********
***This is a try in creating a simple combobox where the user can add values in an input field and also select items from the list. For validation purposes (as required in one of my projects) the input displays red background if the value does not match one in the list, green if the value matches**************

****** Happy if anyone wants to fork and update this script**********
*****Thanks*********/

$(document).ready(function () {
    var combolist = [];
    var combolist2 = [];

    $(".combobox").each(function () {

        $("input", this).focus(function () {
            $(this).parent().find("ul").slideDown();
        });
        //shows dropdown when element focuses

        $("input", this).focusout(function () {
            $(this).parent().find("ul").slideUp();
        });
        //hides element when out of focus

        $("ul li", this).each(function () {
            $(this).click(function () {
                $(this).parent()
                    .parent()
                    .find("input")
                .val($(this).text())
                .css("background","#fff");
            }); //value of li is set as the text value
            combolist.push($(this).text());
            //pushes values of li to an array  
            combolist2.push($(this).text().toLowerCase());
            /*pushes values of li to an array in lowercase -
          added just in case the user does not want the values to be case sensetive  */
        }); //each li


        $("input", this).keyup(function () {
            var val = $(this).val();
            if ($.inArray(val, combolist) > -1 || $.inArray(val, combolist2) > -1) {
                $(this).css("background", "#5CB85C")
            } else {
                $(this).css("background", "#D9534F")
            }
        });

    });

});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console