Solved

Select / Drodown button display issue

Posted on 2008-06-23
9
241 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ebay style="image-orientation: 90deg;" 2 41
How to make a moving character 3 62
Html5 Index on a table 7 29
Increase the size of the modal in Bootstrap 5 28
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

825 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