Solved

Select / Drodown button display issue

Posted on 2008-06-23
9
253 Views
Last Modified: 2011-09-20
Dear Experts,

In the following situation (see code).

I want the unexpanded dropdown to be limited to 50px. However, when the user click on the drop down I want the options to be display at its full length. How do you do that?



<SELECT Width="50px" style="width: 50px;">
<OPTION value='1'>i like cookie and cream ice cream</option>
<OPTION value='2'>candy apple is very yummie</option>
</SELECT>

Open in new window

0
Comment
Question by:jsissopainful
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 42

Assisted Solution

by:David S.
David S. earned 100 total points
ID: 21852638
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 100 total points
ID: 21852667
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Dropdown with Tooltips</title>
<style>
#tooltip {
  position: absolute;
  display:none;
  padding:1px 2px 1px 2px;
  border: 1px solid black;
  background-color:#FFFF99;
}
.dropDownWidth{
 width:60px;
}
</style>
<script language="javascript" type="text/javascript">
// This function checks the mouse event
function checkEvent(e) {
 if (!e) var e = window.event;
 if (e.target) targ = e.target;
 else if (e.srcElement) targ = e.srcElement;
 showHideToolTip(targ, e, e.type)
}
// This function shows/hides the tooltip
function showHideToolTip (theDropDown, e, eType)
{
 var toolTipObj = new Object();
 toolTipObj = document.getElementById("tooltip");
 toolTipObj.innerHTML = theDropDown.options[theDropDown.selectedIndex].text;
 if(eType == "mouseout"){
  toolTipObj.style.display = "none";
   } else
 {
  toolTipObj.style.display = "inline";
  toolTipObj.style.top = e.y + 15;
  toolTipObj.style.left = e.x + 10;
 }
}
</script>
</head>
<body>
<div id="tooltip"></div>
<select id="dropDown1" class="dropDownWidth" onMouseOver="checkEvent(this.event);" onMouseOut="checkEvent(this.event);" onMouseMove="checkEvent(this.event);">
<OPTION value='1'>i like cookie and cream ice cream</option>
<OPTION value='2'>candy apple is very yummie</option>
</select>
</body>
</html>
0
 

Author Comment

by:jsissopainful
ID: 21852674
Ouchy thanks .. it is as I feared :(
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jsissopainful
ID: 21852675
any ways to do this without javascript?
0
 
LVL 18

Assisted Solution

by:Rartemass
Rartemass earned 100 total points
ID: 21852690
CSS does this the best.
Go to: www.alistapart.com
This site has heaps of methods and options specific to menus and drop downs. It will even tell you how to get it working in IE6 browsers with javascript.

This link should be similar to what you need.
http://www.alistapart.com/articles/dropdowns/

Basically with CSS you use multilevel lists. Set the width of the first level to 50px.
Then for second level lists set it to a different width.
You can continue having a different width for each level in the menu.

Please post if you have any issues
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 21852709
0
 

Author Comment

by:jsissopainful
ID: 21852732
Dear pratima_mcs,

Thats not what I am looking for :(



Dear Rartemass,

Thats not what I am looking for as well ... also the example in alistapart requires javascript :(
0
 
LVL 18

Expert Comment

by:Rartemass
ID: 21852750
Actually it only requires javascript to work for older browsers such as IE6; and it is only a small amount of scripting.

I understand you want something else though and will keep looking.
0
 
LVL 2

Accepted Solution

by:
jml948 earned 200 total points
ID: 21852832
The only way i can think to do it would be something like this
<html>
<head>
<script type="text/JavaScript" language="JavaScript">
function setWidth( obj, optObj)
{
var fontSize = optObj.style.fontSize.replace("pt","");
var width = (fontSize/1.33) * optObj.text.length;
obj.style.width = width+'px';
}
</script>
</head>
<body>
<select name="list" id="list" style="width:50px; font-size:8pt">
<option style="font-size:8pt" onclick="setWidth(list, this)" value="1">i like cookie and cream ice cream</option>
<option style="font-size:8pt" onclick="setWidth(list, this)" value="2">candy apple is very yummie</option>
</select>
</body>
</html>

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

713 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