![]() |
| ||
| Tooltips for drop down boxes I have a drop down box of a fixed width. That drop down box needs to contain some values that are longer than the desired width. I'm happy for those values to be truncated, but I would like to display the full text in a tooltip (one that I could format to be a multi-lined one) as the option is hovered over (not after you select an option). Does anyone know if there's an event that's generated when scrolling through the options of a drop down box? I'm taking a guess that there is one, because options are highlighted as you scroll over them, but can you use that event to trigger other functions or is it off limits? Thanks. |
| ||
| Re: Tooltips for drop down boxes |
| ||
| Re: Tooltips for drop down boxes 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() I only need this to work in IE so I haven't tested it in any other browser. |
| ||
| Re: Tooltips for drop down boxes 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: |
| ||
| Re: Tooltips for drop down boxes Tooltips will be displayed in IE7 but not in IE6. I've heard from others this is because in IE6, when you click on a drop down box the browser gives control to the Operating System, so the browser doesn't know anything about where the mouse is or what it's hovering over, so it doesn't trigger the onmouseover event to display a tooltip. To add the title attributes with Javascript you need to call the addTitleAttributes() function somewhere in your HTML after the drop down box is set. ... You shouldn't need any onmouseover event in the <select> tag. If your just coding in plain HTML you can just add the title tag to each OPTION in the SELECT, you don't need to use Javascript. <option value="One" title="One" selected>One</option> I just needed to add them with Javascript because I was generating the drop down menu with JSF's selectOneMenu which doesn't allow you to add a title attribute for each option when you're coding it. |
| ||
| Re: Tooltips for drop down boxes thank you my friend. now its working for me in IE7. Is there any solution for this to display in IE6 and in other web browsers.????? could u help me on this issue. |
| ||
| Re: Tooltips for drop down boxes I don't think you can make tooltips display in IE6. I haven't tried in other browsers. This is an example of what I've done when I've needed to provide a solution for this problem in IE6. It's for when my option values are of the format name: description. My scripts break this string up so that "name" is left as what is displayed in the drop down box and the longer "description" associated with each name is displayed in a readonly textarea positioned below my drop down box. <html> This mightn't be of any use if you don't have a set format that you could break the string up with. You could modify my code to not break up the string at all and just display the full text in the textarea when you select that option from the drop down box. You could then restrict the width of the drop down box and any text longer than that would be truncated which might look a bit messy, but the full text would be displayed in the textarea. I hope that makes sense. |
| ||
| Re: Tooltips for drop down boxes Thank you very much dude,, we decided to continue with IE7 itself. |
| All times are GMT -4. The time now is 8:46 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC