Prevent highlighting in option/select

B

B

Dear all,

How do I prevent highlighting in <select multiple>?

I'm developing a Javascript application and I want to control
highlighting using styles/background-color, the default highlighting
is annoying because the background colour cannot be seen.


Regards,

B
 
J

Jan C. Faerber

Dear all,

How do I prevent highlighting in <select multiple>?

I'm developing a Javascript application and I want to control
highlighting using styles/background-color, the default highlighting
is annoying because the background colour cannot be seen.

Regards,

B

Now I earned some coffee:


<form>
<select multiple onChange="init();" style="background-color:#55ff55;
color:blue; font-weight:bold;">
<option value="">bli</option>
<option value="">bla</option>
<option value="">blo</option>
<option value="">blu</option>
</select>
</form>

<script>
function init() {
var site = document.menu.popup.selectedIndex;
}
</script>
 
B

B

Thanks for your solution Jan. It doesn't quite work, but it pointed me
in a reasonable direction:

<select multiple onChange="selectedIndex = -1;">
<option value="">bli</option>
<option value="">bla</option>
<option value="">blo</option>
<option value="">blu</option>
</select>

This still isn't ideal because clicking results in highlight followed
by dotted border around item 0 -- this is clearly a vast improvement
on yesterday's solution, but could still be improved upon.

Thanks again,

B
 
B

B

A far worse disadvantage of the above code is that focus is also
shifted to the index -1, i.e. if you have scrolled down a list,
javascript scrolls back up. I suspect the highlighting must be
controlled by some style attribute -- I'm just not sure which!
 
H

Harlan Messinger

B said:
Dear all,

How do I prevent highlighting in <select multiple>?

I'm developing a Javascript application and I want to control
highlighting using styles/background-color, the default highlighting
is annoying because the background colour cannot be seen.

What you're building is a way to confuse your users by making your
multi-select list work differently from other multi-select lists in
their browser.
 
B

B

What you're building is a way to confuse your users by making your
multi-select list work differently from other multi-select lists in
their browser.

Yes I am indeed doing this. But you haven't asked the most important
question: what am I doing? I am using javascript to display multiple
select lists each of which contain a list of options which have
complex interactions with one-and-other. For example selecting item 1,
list 1 prevents the selection of item 3, list 2; and item 4, list 3 is
unavailable unless item 2 list 2 has been selected. Achieving such a
result in a user-friendly manner is a non-trivial task. As standard
advice ``what you're building is a way to confuse your users by making
your multi-select list work differently from other multi-select lists
in their browser" you are correct. But in this context I cannot see
another solution. If I had chosen to use a more heavy weight language
such as Java I would be doing exactly this, but the development time
would have been more excessive.
 
A

Adrienne Boswell

I am assuming no one has a solution to this one then....

The original post has dropped off the news server I am using, so I have no
idea what you are talking about. Next time, make sure and quote the
relavent information.
 

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
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top