Is it possible to set width of select element, the #size will set number of drop down field, is there a property to set width in characters

many thanks

Darko

Comments

dark-o’s picture

I worked out how to do it with CSS, so for others here is the answer:
use #prefix to set divs with class:

 '#prefix' => '<div class="publishedSelect">',  
 '#suffix' => '</div>',

then change size in CSS:

.publishedSelect {  width:70px;  margin:10px 0px 0px 0px; }
alextronic’s picture

This will only wrap the select into a

70px wide, but if the select is smaller than that, it will not expand to be 70px wide itself. We need to force the select box to be exactly 70px wide regardless of its options are bigger or smaller than that.

Anyone?

alextronic’s picture

I can only think of using jQuery...

  $(document).ready(function(){
    $(".publishedSelect").css("width", "70px");
  });
scotthorn’s picture

Version: 6.14 » 7.0
Status: Active » Fixed

I found a way where you can still use css with the prefix, suffix options. The div class you give it contains another div which contains the select field, so the css looks like this:

.publishedSelect div select {
  width: 200px;
}

I'm using drupal 7, though. It's possible that drupal 6 renders the divs differently, but the method should still work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.