473,287 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

On change event of <select> in Firefox doesn't fire when using cursor keys

I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't seem to fire until
I've left the field....If i use the mouse all is fine, only when using
the cursor keys does it not fire the onchange event in FF.
Thanks for any help in advance.
Michael

Aug 14 '05 #1
14 23170
ASM
xx********@supergambler.com wrote:
I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't seem to fire until
I've left the field....If i use the mouse all is fine, only when using
the cursor keys does it not fire the onchange event in FF.


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
Aug 14 '05 #2
xx********@supergambler.com wrote:
I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't seem to fire until
I've left the field....If i use the mouse all is fine, only when using
the cursor keys does it not fire the onchange event in FF.


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
Aug 14 '05 #3
ASM
RobG wrote:
Firefox does wait if you use the keyboard, but
not if you use the mouse.
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)
--
Stephane Moriaux et son [moins] vieux Mac
Aug 14 '05 #4
ASM wrote:
RobG wrote:
Firefox does wait if you use the keyboard, but not if you use the mouse.

Not at all :


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
Aug 15 '05 #5
ASM
RobG wrote:

So we have variation not only between browsers, but in the same browser
on different platforms. It just gets better... :-x


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 (?)
--
Stephane Moriaux et son [moins] vieux Mac
Aug 15 '05 #6
ASM wrote:
RobG wrote:

So we have variation not only between browsers, but in the same
browser on different platforms. It just gets better... :-x

because sometimes I have some difficulties with my English ...


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
Aug 15 '05 #7
Thanks for the reply Rob, What I am trying to achieve is when the user
selects an item in the list, depending on the selection I want to
enable and make visible some other objects on the page. I have a real
pain in the ass supervisor who doesn't think my idea to make the
current project run in a browser versus a client / server app, and one
of her things is being able to use the keyboard and not have to switch
back and forth between keyboard and mouse.....so in my attempt to prove
myself right and her wrong, I really need this to work with just using
the keyboard down arrow and up arrow.....now one thought I did have
since the event fires when I tab away from the list, is in the function
that fires, I could set the focus to the first enabled object that the
routine just made enabled thus giving the illusion that it's doing what
I want.....

Any other thoughts or ideas would be greatly appreciated.....

Thanks in advance!

Michael

Aug 15 '05 #8
xx********@supergambler.com wrote:
Thanks for the reply Rob, What I am trying to achieve is when the user
selects an item in the list, depending on the selection I want to
enable and make visible some other objects on the page. I have a real
pain in the ass supervisor who doesn't think my idea to make the
current project run in a browser versus a client / server app, and one
of her things is being able to use the keyboard and not have to switch
back and forth between keyboard and mouse.....so in my attempt to prove
myself right and her wrong, I really need this to work with just using
the keyboard down arrow and up arrow.....now one thought I did have
since the event fires when I tab away from the list, is in the function
that fires, I could set the focus to the first enabled object that the
routine just made enabled thus giving the illusion that it's doing what
I want.....

Any other thoughts or ideas would be greatly appreciated.....

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">&nbsp;</div>

</body>
Thanks in advance!

Michael

--
Rob
Aug 15 '05 #9
ASM
RobG wrote:
ASM wrote:

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.


That's right : FF, IE, Safari

click on select -> list displayed
arrow key -> moves line to line
Enter key -> validation and onchange
--
Stephane Moriaux et son [moins] vieux Mac
Aug 15 '05 #10
ASM
xx********@supergambler.com wrote:
I really need this to work with just using
the keyboard down arrow and up arrow.....now one thought I did have
since the event fires when I tab away from the list, is in the function
that fires, I could set the focus to the first enabled object that the
routine just made enabled thus giving the illusion that it's doing what
I want.....

Any other thoughts or ideas would be greatly appreciated.....


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
--
Stephane Moriaux et son [moins] vieux Mac
Aug 15 '05 #11
RobG wrote:
onkeyup introduces a touch of lag, onkeydown selects the previous option
(maybe that's OK?). <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

Aug 15 '05 #12
I like it!!! Thanks so much!

Aug 16 '05 #13
xx********@supergambler.com wrote :
I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't seem to fire until
I've left the field....If i use the mouse all is fine, only when using
the cursor keys does it not fire the onchange event in FF.
Thanks for any help in advance.
Michael


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
Aug 16 '05 #14
ASM
Gérard Talbot wrote:
xx********@supergambler.com wrote :
I have a <select> object that i've set up an onchange event that fires
in IE fine when I use the cursor up and down in the list, but If I use
the cursor up and down in Firefox the event doesn't seem to fire
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
--
Stephane Moriaux et son [moins] vieux Mac
Aug 17 '05 #15

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

Similar topics

3
by: K. Lobe | last post by:
list box based on a POST method to the same page. frm.cmbList.Value=Request.Form("cmbList") doesn't work. When the page loads, it reloads the <SELECT>, so not sure how to get the list to go to...
7
by: Hal Vaughan | last post by:
I have a sample script from a book ("Beginning JavaScript" by Paul Wilton) that removes or adds a choice to a <SELECT> element. The <FORM> is form1 and the <SELECT> is theDay. The example uses...
2
by: Aaron C | last post by:
This is kindof a newbie question, so please bear with me... I need to pass the selected option of a <select> tag into a query string, so that the page is reloaded with the selected option already...
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
3
by: i_dvlp | last post by:
I'm trying to replicate a fancy drop-down control (MS-egads!) with form <select><option> It doesn't look like you can specity width as an attribute or define width with CSS. It looks like my...
5
by: Isha | last post by:
Hi all, I wanted to change the background color for only the first option in a select box, but following changed the background color for the whole dropdown box. <select name="alltags"...
8
by: dkate777 | last post by:
I have a PHP/mySQL database running, and I've realized I'm come across an awkward little bug. I have a form where a user fills out their information using populated drop down boxes. This...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.