Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 08:13:15 AM

Pages: [1]   Go Down
  Print  
Author Topic: Shortening a drop down box  (Read 596 times)
ziange
Spacescooter Operator
*****
Offline Offline

Posts: 39


WWW
« on: November 14, 2011, 07:55:04 PM »

Hi, i have a drop down box in a table with a bunch of project names, but some of them are pretty long. The drop down is taking up all the screen space. Is there a way to shorten the box, so you click on the drop down, look at the full names, and when you've selected one it shows only part of it, say the first 10 letters? Thanks!
Logged

MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5219



« Reply #1 on: November 17, 2011, 09:06:58 AM »

So you're looking for an "L-shaped" drop-down box? That is, when not in use, a short box showing only the beginning of the selected text, and when you open it, the listed choices (below) are full length (while the short box stays short)? That's gonna be tricky. You can easily limit the size of the select box with CSS "width", but I don't know of any way to override that for the listed choices (i.e., it appears that they inherit the select short box's length). I suppose that you could add Javascript to change the styling (width) of the select box on mouseover or click, but that would probably rearrange your page to fit the lengthened element.

What you might end up doing is faking a select box in Javascript, to pop up a <div> with a number of choices and a scrollbar, each with their own Javascript to select/deselect. It will be complicated, but I'm sure it can be done in some manner. The hardest part will be positioning the pop-up so it's fully on page, yet adjacent to the "select" box. Have you googled for this? I can't believe that someone hasn't solved this problem before.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1]   Go Up
  Print  
 
Jump to: