User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 330,335 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,726 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Tooltips for drop down boxes

Join Date: Mar 2008
Posts: 3
Reputation: arvindgally is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arvindgally arvindgally is offline Offline
Newbie Poster

Re: Tooltips for drop down boxes

  #4  
Mar 25th, 2008
i tried out adding titles using javascript. But i'm not getting the tool tip.
can u help me to bring the tool tip for each and every options in the select control
.

my HTML Code:
  1. <select id="DropDownList1" onmouseover='showHideTooltip();' size='5'style="LEFT: 104px;POSITION: absolute; TOP: 160px;Width:180px;z-index:9999;">
  2. <option Value="One" Selected="True">One</option>
  3. <option Value="Two">Two</option>
  4. <option Value="Three">Threee</option>
  5. <option Value="Four">Four</option>
  6. <option Value="Five">Five</option>
  7. </select>
  8.  
  9. my javascript Code:
  10. function addTitleAttributes()
  11. {
  12. numOptions = document.getElementById('DropDownList1').options.length;
  13. for (i = 0; i < numOptions; i++)
  14. document.getElementById('DropDownList1').options[i].title = document.getElementById('DropDownList1').options[i].text;
  15. alert('completed');
  16. }

Originally Posted by mowen85 View Post
Thanks for your reply, but I'd just already worked out a solution.

When an OPTION in a SELECT has a TITLE attribute, the value of TITLE is automatically shown as a tooltip when you hover over that option. My problem was that I'm using JSF and in that, the way that a drop down menu is dynamically generated doesn't allow for title tags to be added so I thought I'd have to make some tooltips manually.

I've been mucking around in Javascript though and have created a function to call after the page has loaded (and the drop down box has been generated) that will set the TITLE attribute for each OPTION to be whatever the text of that option is. This allows me to have my truncated options but still view the full text by hovering over them.

function addTitleAttributes()
{
   numOptions = document.getElementById('comboBox').options.length;
   for (i = 0; i < numOptions; i++)
      document.getElementById('comboBox').options[i].title =
            document.getElementById('comboBox').options[i].text;
}

I only need this to work in IE so I haven't tested it in any other browser.
Last edited by peter_budo : Mar 27th, 2008 at 2:35 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
All times are GMT -4. The time now is 9:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC