473,785 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display an individual tooltip for each item in a listbox (select box)

Hello,

Using MSIE 6.0 and above, with javascript is it possible to display an
individual tooltip for each item in a listbox?

I need this functionality to show the listitems that are longer than the
listbox size.

Please refer to this link to get the idea of what I would like to do.
Unfortunately this one is for VB.

http://www.codeguru.com/vb/controls/...cle.php/c2767/

Is there any event that I can catch when I am moving between the items
in listbox selection? Is it possible to get the value of the item
currently selected while expanding the listbox?

Thanks in advanced.

rgs,
hiroshi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #1
5 14038
hiroshi ochi wrote:
Is there any event that I can catch when I am moving between the items
in listbox selection? Is it possible to get the value of the item
currently selected while expanding the listbox?


While onMouseOver works on the Select tag it doesn't work on the
individual items in the option tags (In IE anyway). This means you
can't really use a select box to do what you want to do. Fortunately
you can simulate this effect.

Create a new HTML page and have it be nothing but your select list
as
<A HREF="javascrip t:parent.boxCli ck(1)">A really, really, really long
list item 1</A>
<A HREF="javascrip t:parent.boxCli ck(2)">A really, really, really long
list item 2</A>
etc.

Now use an iframe on your main page to display your list (as narrow as
you want as large as you want). To prevent horizontal scrolling in your
iframe in your <BODY> in the list (not the main page) do this... <body
style="overflow-x:hidden; overflow-y: auto;">

On your main page create a function called boxClick(value) that sets the
value of a hidden field. When the user clicks in the iframe it will
call boxClick on your main page with the value the user clicked on.

Now as for the individual tooltips there's already a very powerful
pre-existing flyover tooltip maker at http://www.bosrup.com/web/overlib/
-- in your list html just include the overlib.js script, and set
onmouseover and onmouseout events for each link as described in the
documentation.

It's a lot of work to get around a failing in IE but it can be done and
in a way that will remain true to your vision.

Hope this helps you out a bit.
Jul 23 '05 #2
pcx99 wrote:

<--snip-->
Create a new HTML page and have it be nothing but your select list
as
<A HREF="javascrip t:parent.boxCli ck(1)">A really, really, really long
list item 1</A>
<A HREF="javascrip t:parent.boxCli ck(2)">A really, really, really long
list item 2</A>
etc.


http://www.jibbering.com/faq/#FAQ4_24

Better would be:

<a href="URLToGoTo WithJSDisabled. html"
onclick="parent .boxClick(this. href)">A really......... </a>

And simply pass the href property, and have boxClick navigate accordingly.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 23 '05 #3
Thanks pcx99 and Randy for your reply and information.

If possible, I would like to avoid using iframe because there will be
too much amendment I have to do in my application.

The main problem I am facing right now is that the width I can assign
for each listbox is limited, but the text contents of each items in
listbox is pretty long. Thus, it will be hard for user to select items
that looks the similar.

First, I thought of using tooltip to assist user to select, but then I
got another simpler idea by using <span> to wrap the <select> tag. I
just set the <span> width to a certain value, and not restricting the
width in the <select> part.

Please take a look at the sample code below (tested in MSIE 6.0):
<!-- start sample code -->
<html>
<script>
function setLabelSpan(el ement){
var label = document.getEle mentById('label Span');
label.innerHTML =element.option s[element.selecte dIndex].text;
}
function setLabelNoSpan( element){
var label = document.getEle mentById('label NoSpan');
label.innerHTML =element.option s[element.selecte dIndex].text;
}
</script>
<body>
<form >
<table border="1" bordercolor="#0 00000">
<tr>
<td nowrap>Using Span </td>
<td><span style="overflow :hidden;width:1 50px">
<select name="select" border=0 onchange="setLa belSpan(this)">
<option value="">Select Product Code</option>
<option value="100">AE0 00 : Johnson's Baby Lotion (A/V)(G) -
100mlx24 </option>
<option value="101">AE0 01 : Johnson's Baby Lotion (A/V)(G) -
200mlx24 </option>
<option value="102">AE0 02 : Johnson's Baby Lotion (A/V)(G) -
400mlx24 </option>
<option value="103">AE0 03 : Johnson's Baby Lotion (A/V)(G) -
800mlx24 </option>
<option value="104">AE0 04 : Johnson's Baby Lotion (A/V)(G) -
100mlx72 </option>
<option value="105">AE0 05 : Johnson's Baby Lotion (A/V)(G) -
200mlx72 </option>
<option value="106">AE0 06 : Johnson's Baby Lotion (A/V)(G) -
400mlx72 </option>
<option value="107">AE0 07 : Johnson's Baby Lotion (A/V)(G) -
800mlx72 </option>
<option value="108">AE0 08 : Johnson's Baby Lotion (A/V)(N) -
100mlx24 </option>
<option value="109">AE0 09 : Johnson's Baby Lotion (A/V)(N) -
200mlx24 </option>
<option value="110">AE0 10 : Johnson's Baby Lotion (A/V)(N) -
400mlx24 </option>
<option value="111">AE0 11 : Johnson's Baby Lotion (A/V)(N) -
800mlx24 </option>
<option value="112">AE0 12 : Johnson's Baby Lotion (A/V)(N) -
100mlx72 </option>
<option value="113">AE0 13 : Johnson's Baby Lotion (A/V)(N) -
200mlx72 </option>
<option value="114">AE0 14 : Johnson's Baby Lotion (A/V)(N) -
400mlx72 </option>
<option value="115">AE0 15 : Johnson's Baby Lotion (A/V)(N) -
800mlx72 </option>
</select>
</span> </td>
</tr>
<tr>
<td nowrap>Without Span </td>
<td>
<select name="select" style="overflow :hidden;width:1 50px" border=0
onchange="setLa belNoSpan(this) ">
<option value="">Select Product Code</option>
<option value="100">AE0 00 : Johnson's Baby Lotion (A/V)(G) -
100mlx24 </option>
<option value="101">AE0 01 : Johnson's Baby Lotion (A/V)(G) -
200mlx24 </option>
<option value="102">AE0 02 : Johnson's Baby Lotion (A/V)(G) -
400mlx24 </option>
<option value="103">AE0 03 : Johnson's Baby Lotion (A/V)(G) -
800mlx24 </option>
<option value="104">AE0 04 : Johnson's Baby Lotion (A/V)(G) -
100mlx72 </option>
<option value="105">AE0 05 : Johnson's Baby Lotion (A/V)(G) -
200mlx72 </option>
<option value="106">AE0 06 : Johnson's Baby Lotion (A/V)(G) -
400mlx72 </option>
<option value="107">AE0 07 : Johnson's Baby Lotion (A/V)(G) -
800mlx72 </option>
<option value="108">AE0 08 : Johnson's Baby Lotion (A/V)(N) -
100mlx24 </option>
<option value="109">AE0 09 : Johnson's Baby Lotion (A/V)(N) -
200mlx24 </option>
<option value="110">AE0 10 : Johnson's Baby Lotion (A/V)(N) -
400mlx24 </option>
<option value="111">AE0 11 : Johnson's Baby Lotion (A/V)(N) -
800mlx24 </option>
<option value="112">AE0 12 : Johnson's Baby Lotion (A/V)(N) -
100mlx72 </option>
<option value="113">AE0 13 : Johnson's Baby Lotion (A/V)(N) -
200mlx72 </option>
<option value="114">AE0 14 : Johnson's Baby Lotion (A/V)(N) -
400mlx72 </option>
<option value="115">AE0 15 : Johnson's Baby Lotion (A/V)(N) -
800mlx72 </option>
</select>
</td>
</tr>

</table>
<br> Selected Value using span = <span id="labelSpan"> </span>
<br> Selected Value without span = <span id="labelNoSpan "></span>
</form>
</body>
</html>

<!-- end sample code -->
The row 'without span' in the table is what the original looks like, and
row 'using span' is after using the span.

I hope this one idea can help another people too.

thanks,
hiroshi
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4
hiroshi ochi wrote:
Hello,
Using MSIE 6.0 and above, with javascript is it possible to display an
individual tooltip for each item in a listbox?

<snip>

If you don't mind using a div, and document.getEle mentById which has
limited browser support, take a look at this page (see last code
example). It updates the text in a div. If you want you can track the
mouse, move the div to the right of the mouse and make it visible when
it is over the select options, make bkg yellow to look like a VB tooltip
if you want.

http://www.experts-exchange.com/Web/..._20942527.html

Mike

Jul 23 '05 #5
Hello Mike,

Thanks for the information.

I tried the code you mentioned. Yes this behaviour imitates the vb
example that I refered.

I think this one is very handy in a listbox with size more than 0.
Unfortunately, in this particular problem, I have to handle the listbox
with size 0. My apologies for not explaining this in advanced.

But I believe I still can utilize this in other part of my application.
Thanks very much!

rgs,
hiroshi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1818
by: SHYAM SUNDAR E G | last post by:
hi, I want to display tooltip when Hovered on the Combo Box. like, once if we click on the combo, displays all items in the Combo, when i move the mouse on each item, it has to display the tooltip with that Itemname. Reason: some times item names will be larger then combo box width. i want to display them as Tooltips. will u please suggest with solution. waiting for reply
2
7872
by: C Chang | last post by:
When I used the tooltip box to display tip message on a label or an image next to an input box or several input boxes nearby, the part of the tip will be covered by the area of the input box. (provided the tip box is big, and there is no enough blank space to post the tip). Does anyone know how to avoid and which attribute can make the tip on top of all objects on the page? The tip box message is built in the javascript section of the...
4
5113
by: Colleyville Alan | last post by:
I am trying to use a list box to allow users to select items, the results are queried based on the selection and written to a spreadsheet. If the item already exists on their current spreadsheet, I'd like to indicate that so that they do not choose the same item a second time. Right now, I have the listbox show those items that are already on the spreadsheet using the selection property (selected = true). But that actually increases...
3
3615
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name in the subform. Is it possible? How do I do this? Thanks in advance. Paul from Slovakia
18
3352
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information from the dataset and how can I do that? Also, I set the property of the listbox to selectionmode...
3
1878
by: Shiju Poyilil | last post by:
Is there anyway to assign tooltip dynamically to the list items in the listbox in asp.net. Rgds Shiju
4
5482
by: NewAlias | last post by:
How to display comments for each enum entry? 'Enum example with commnents commented Private Enum MyEnum YourName =1 ' Set this to get your real name YourAge=2 ' Set this to get your real age YourNationality=3 ' Set this to retrieve your real nationality End Enum
5
2855
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that is what the ListBox uses for its display. Correct?
4
2490
by: SenileOwl | last post by:
I'm working with Visual Basic .Net 2005 I'm trying to create a tooltip for a bound listbox and a combobox. I want the tooltip to be of the item the mouse is hovering over. Is there an easy way to do this? I stumbled across some code that required identifying the position of the mouse in X, Y and then finding the height of each item, etc, etc. Is that going to be my best option?
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.