Thanks for any help in advance.
Michael
What do you call cursors ? (are they arrows in scrollbar of list ?)
on my Mac, with arrow keys up and/or down of keyboard :
- IE scrolls window
- FF does what you say your IE does
--
Stephane Moriaux et son [moins] vieux Mac
I guess your unasked question is "How do I get consistent behaviour" -
the answer is to not use a select to fire onchange events (which is
probably not what you want to hear).
The W3C spec says that onchange should fire when the control loses focus
(provided the value has changed). IE doesn't wait, it fires as soon as
the option is selected. Firefox does wait if you use the keyboard, but
not if you use the mouse.
There are other inconsistencies between various browsers and the spec,
unfortunately the result is a bit of a mess.
If you explain what you are trying to do some other solution can be
proposed.
--
Rob
Not at all :
on my Mac with my FF (doctype transitional 4.0)
it fires on each change (by keyboard's arrow key or by click)
(scrolling list by lift or mouse well -> no change or fire)
> There are other inconsistencies between various browsers and the spec,
> unfortunately the result is a bit of a mess.
unfortunatly (soupir)
Perhaps I should have said 'Firefox on Windows'.
> on my Mac with my FF (doctype transitional 4.0)
> it fires on each change (by keyboard's arrow key or by click)
> (scrolling list by lift or mouse well -> no change or fire)
So we have variation not only between browsers, but in the same browser
on different platforms. It just gets better... :-x
[...]
--
Rob
because sometimes I have some difficulties with my English ...
my test was :
<select size=4 onchange="alert(this.options[this.selectedIndex].text);">
<option>test 1
<option>test 2
<option>test 3
<option>test 4
<option>test 5
<option>test 6
<option>test 7
</select>
hope was right subject of post (?)
Hey, you're English is fine - certainly better then my French!
> my test was :
>
> <select size=4 onchange="alert(this.options[this.selectedIndex].text);">
----------^^^^^^
The size attribute actually changes the behaviour of the select's
onchange event in Firefox (Windows XP). If size is 1 or not defined,
the onchange does not fire using the keyboard until the select loses
focus. With a size attribute of 2 or greater, the onchange fires every
time an option is selected with the keyboard.
Is it the same for Safari et al?
[...]
--
Rob
Any other thoughts or ideas would be greatly appreciated.....
Thanks in advance!
Michael
You can use a combination of onkeyup and onchange, which seems to work
OK (read thread above). You should have a reset function that returns
the form to the default onload (otherwise some browsers will show a
selected option that does not match the page content), if you want it to
act more like a form, then a reset button should be included too (see
example below).
onkeyup introduces a touch of lag, onkeydown selects the previous option
(maybe that's OK?).
<body onload="document.formA.reset();">
<script type="text/javascript">
function changeIt( el ){
var x = document.getElementById('xx').firstChild;
x.data = el.options[el.selectedIndex].text;
}
</script>
<form action="" id="formA" name="formA">
<select name="selectA" size="1"
onchange="changeIt( this );"
onkeyup ="changeIt( this );"
>
<option selected>
<option>test 1
<option>test 2
<option>test 3
<option>test 4
<option>test 5
<option>test 6
<option>test 7
</select>
<input type="reset" onclick="
this.form.selectA.selectedIndex=0;
changeIt(this.form.selectA);
">
</form>
<div id="xx"> </div>
</body>
> Thanks in advance!
>
> Michael
>
--
Rob
That's right : FF, IE, Safari
click on select -> list displayed
arrow key -> moves line to line
Enter key -> validation and onchange
on my Mac and with a select not defined size or set to 1
IE, FF, Safari -> same way :
1) click on select (or tab-indexed ?) -> list displayed
2) Arrow key -> moves line to line
3) Enter key -> validation and onchange fired
> <select name="selectA" size="1"
> onchange="changeIt( this );"
> onkeyup ="changeIt( this );"
> >
replace that onkeyup line with
onkeydown="window.setTimeout(function(e0){return
function() {changeIt(e0)}}(this),0)"
to get that spiffy, lagless performance you've been dreaming about. It
also responds to each item when the arrow keys are held down, hence
repeat.
Tested on IE, FF under Win XP Pro
Csaba Gabor from Vienna
That's by design.
Select onChange not called using down arrow key
https://bugzilla.mozilla.org/show_bug.cgi?id=126379
and this bug has at least 25 duplicates.
Gérard
--
remove blah to email me
> That's by design.
>
> Select onChange not called using down arrow key
> https://bugzilla.mozilla.org/show_bug.cgi?id=126379
>
> and this bug has at least 25 duplicates.
the real question : is it a bug in FF/Mozilla or is it in IE ?
if, going thru options, fires each next ... not a good idea
FF select onchange : up/down arrow then, if good, Enter key