How to prevent focus of a select object?
Anyone know how to prevent the focus of the SELECT guy?
I want to disable it, but the disabled=true blurs out the text.
I currently have an ONFOCUS event handler that checks my criteria and calls element.focus() or element.blur().
This works for the textboxes but not SELECT.
Any help would be appreciated!
Well I would have thought this would work:
EDIT: having re-read it I get the impression you're setting the disabled attribute through JS anyway, so my last comments was a bit pointless
Well I am using IE 5.0+ on win2000. Id have thought this.blur() would have worked. Try it, I sure cant get it going
Turns out the only way to prevent modification without disabling (which affects visibility) is to REDIRECT the focus! And not only that you have to replace several methods:
<select onmousedown="blah(this);" ondblclick="blah(this);" onfocus="blah(this);">
(Can't remember the exact spelling of the onmousedown method)
if (my criteria to prevent changes == true)
Incidentally, if given an element, is there a quick way to get the next element or previous element in the form element array?
You're right it doesn't work in IE, although it does work in Opera and Mozilla, so I can only put it down to a bug with events and <select>. I did think of returning false onfocus/click/mousedown but that doesn't work either. Not sure about the next/prev elements thing, sorry.
Have you tried setting the TABINDEX="-1"?
"3.Objects with a negative tabIndex are omitted from the tabbing order."
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)