select list

S

Stephen Chalmers

Ayrton said:
I need to have tooltips in a select list (or combo ), are there some
examples ?

None that I could find, other than by simulating a select box in CSS.
The following works in the Mozilla family only. In I.E. and Opera I could not add mouseover events successfully to the
option elements. Perhaps someone else can.

<HTML>
<BODY>

<DIV ID='optionTip'>&nbsp;</DIV><BR>

<FORM name='f1'>
<SELECT name='actions'>
<OPTION value='moon'>Moon</OPTION>
<OPTION value='earth'>Earth</OPTION>
<OPTION value='mercury'>Mercury</OPTION>
</SELECT>
</FORM>

<SCRIPT type="text/javascript">
var optionHelp=['Pull the Moon out of orbit',
'Collide the Earth with Mars',
'Collide Mercury with Venus' ];

if(document.forms.f1.innerHTML)
with(document.forms.f1)
for(var i=0; i<actions.length; i++)
{
actions.options.onmouseover=new Function("document.getElementById('optionTip').innerHTML=optionHelp["+i+"];");
actions.options.onmouseout=function(){document.getElementById('optionTip').innerHTML='&nbsp;';};
}

</SCRIPT>
</BODY>
</HTML>
 
A

Ayrton

Sembra che Stephen Chalmers abbia detto :
Ayrton said:
I need to have tooltips in a select list (or combo ), are there some
examples ?

None that I could find, other than by simulating a select box in CSS.
The following works in the Mozilla family only. In I.E. and Opera I could
not add mouseover events successfully to the option elements. Perhaps
someone else can.

<HTML>
<BODY>

<DIV ID='optionTip'>&nbsp;</DIV><BR>

<FORM name='f1'>
<SELECT name='actions'>
<OPTION value='moon'>Moon</OPTION>
<OPTION value='earth'>Earth</OPTION>
<OPTION value='mercury'>Mercury</OPTION>
</SELECT>
</FORM>

<SCRIPT type="text/javascript">
var optionHelp=['Pull the Moon out of orbit',
'Collide the Earth with Mars',
'Collide Mercury with Venus' ];

if(document.forms.f1.innerHTML)
with(document.forms.f1)
for(var i=0; i<actions.length; i++)
{
actions.options.onmouseover=new
Function("document.getElementById('optionTip').innerHTML=optionHelp["+i+"];");

actions.options.onmouseout=function(){document.getElementById('optionTip').innerHTML='&nbsp;';};
}

</SCRIPT>
</BODY>
</HTML>


I've try your example, but the event mouseover don't fire when the
mouse il over an item of select.
My browser is IE 6.0
 
S

Stephen Chalmers

Ayrton said:
I've try your example, but the event mouseover don't fire when the
mouse il over an item of select.
My browser is IE 6.0

Which is quite consistent with what I said.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top