473,241 Members | 1,597 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,241 software developers and data experts.

Onchange et Firefox...

Hi,

I have a big problem with a simple event : onchange !!!
If I write this page :
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="return false;"/>
</form>
</body>
</html>
everything is ok in IE (I can't leave the input zone !) but nothing
happens in Firefox !!!
It looks like the event is not fired or...

Do you have any clue ?

Thank you very much.

David.

Jul 11 '06 #1
10 4889
da**********@wanadoo.fr said the following on 7/11/2006 4:01 AM:
Hi,

I have a big problem with a simple event : onchange !!!
Contrary to your Subject line, it seems IE is the one that is wrong.
If I write this page :
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="return false;"/>
</form>
</body>
</html>
What do you think that code is supposed to do? You are telling it "When
this gets changed, do nothing". Well, that is what Firefox does - nothing.
everything is ok in IE (I can't leave the input zone !) but nothing
happens in Firefox !!!
You are going about it the wrong way then. onchange="this.focus()"
It looks like the event is not fired or...
Or you are trying to solve the wrong problem the wrong way.
Do you have any clue ?
I have lots of clues, how many do you want?

Answers are free, clues are 100 Dollars US each.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 11 '06 #2
Randy Webb wrote:
da**********@wanadoo.fr said the following on 7/11/2006 4:01 AM:
Hi,

I have a big problem with a simple event : onchange !!!

Contrary to your Subject line, it seems IE is the one that is wrong.
OK. May be my explanation was wrong ;-)
If I write this page :
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="return false;"/>
</form>
</body>
</html>

What do you think that code is supposed to do? You are telling it "When
this gets changed, do nothing". Well, that is what Firefox does - nothing.
I'd like the user to stay in the input zone.
everything is ok in IE (I can't leave the input zone !) but nothing
happens in Firefox !!!

You are going about it the wrong way then. onchange="this.focus()"
It changes nothing !!!
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="this.focus()"/>
<input id="var02" name="var02" size="5" onchange="this.focus()"/>
</form>
</body>
</html>
If I am in the var01 zone, I change the value and then "tab", I go to
the var02 zone !!!
It doesn't work in IE too...
It looks like the event is not fired or...

Or you are trying to solve the wrong problem the wrong way.
Perhaps...
In IE, it seems simple. I am in a zone, I verify the value. If it is
ok, I do nothing (so, the user will go in the next zone) and if the
value is wrong, I say "return false" and the user stays in this zone
!!!
If you have other solution, I'm ok ;-)
Do you have any clue ?

I have lots of clues, how many do you want?
Good question ;-) Only the best one ;-)

David.
Answers are free, clues are 100 Dollars US each.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 11 '06 #3
Rik
David BERCOT wrote:
I'd like the user to stay in the input zone.
>>everything is ok in IE (I can't leave the input zone !) but nothing
happens in Firefox !!!

You are going about it the wrong way then. onchange="this.focus()"

It changes nothing !!!
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="this.focus()"/>
<input id="var02" name="var02" size="5" onchange="this.focus()"/>
</form>
</body>
</html>
If I am in the var01 zone, I change the value and then "tab", I go to
the var02 zone !!!
It doesn't work in IE too...

onblur="this.focus()"
Grtz,
--
Rik Wasmus
Jul 11 '06 #4

Rik wrote:
David BERCOT wrote:
I'd like the user to stay in the input zone.
>everything is ok in IE (I can't leave the input zone !) but nothing
happens in Firefox !!!

You are going about it the wrong way then. onchange="this.focus()"
It changes nothing !!!
<html>
<body>
<form id="vu">
<input id="var01" name="var01" size="5" onchange="this.focus()"/>
<input id="var02" name="var02" size="5" onchange="this.focus()"/>
</form>
</body>
</html>
If I am in the var01 zone, I change the value and then "tab", I go to
the var02 zone !!!
It doesn't work in IE too...


onblur="this.focus()"
Not better !!! This is ok with IE but not with Firefox...

David.

Jul 11 '06 #5
"Rik" <lu************@hotmail.comwrites:
onblur="this.focus()"
Which, while perhaps solving the OP's stated problem, is something
one should never write in a web page. It makes navigating away
from the input control impossible, which is extremely user-unfriendly,
and in the case of someone using keyboard navigation, you can't even
click on buttons anywhere else on the page.

/l
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 11 '06 #6
Lasse Reichstein Nielsen wrote:
"Rik" <lu************@hotmail.comwrites:
onblur="this.focus()"

Which, while perhaps solving the OP's stated problem, is something
one should never write in a web page. It makes navigating away
from the input control impossible, which is extremely user-unfriendly,
and in the case of someone using keyboard navigation, you can't even
click on buttons anywhere else on the page.
Of course, I should not use this like that. It would be in a function
with a test...
But, before this test, I don't understand why this function does not
work in Firefox !!!

Do you have any idea ?

Thank you.

David.

Jul 11 '06 #7
David BERCOT wrote:

[...]
onblur="this.focus()"

Not better !!! This is ok with IE but not with Firefox...
Here it is, but it's really dirty:

<input onblur="this.focus()">
<input onfocus="this.blur()">

--
Bart

Jul 11 '06 #8
"David BERCOT" <da**********@wanadoo.frwrites:
Lasse Reichstein Nielsen wrote:
>"Rik" <lu************@hotmail.comwrites:
onblur="this.focus()"
....[don't]...
Of course, I should not use this like that. It would be in a function
with a test...
Still, it's not good user interface design to prevent the user from
doing what he wants to do.

It's much better, safer, and coincidentally also easier to implement,
to mark an erroneous field as such and just prevent submission, than
it is to prevent navigation.
Let people write garbage if that is what they want. Just tell them
that it's garbage and (attemp) to stop them submitting it (but check
on the server anyway).
But, before this test, I don't understand why this function does not
work in Firefox !!!
It's a matter of timing. When you try to leave an input control,
the browser fires a number of events - onblur, onchange and onfocus
(on the new control). It happens in roughly that order (at least
in Firefox).
It corresponds to the browser first removing focus from one control
and then setting it on another. In some browsers, setting the focus
back in on of the first two event handlers will work, in Firefox,
the setting of the focus to the other control will still happen
afterwards.

What you could do was have a check when you leave a field, that sets
stores the erroneous field somewhere, and then, onfocus in the other
controls, see if there is an erroneous control and set focus back.

But still, it's bad design!
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 11 '06 #9
Still, it's not good user interface design to prevent the user from
doing what he wants to do.
I don't agree but this is not the subject ;-)
In fact, it depend of the application and the public. In my case, it is
normal to prevent the user from leaving the input zone...
What you could do was have a check when you leave a field, that sets
stores the erroneous field somewhere, and then, onfocus in the other
controls, see if there is an erroneous control and set focus back.
Hum, it is quite difficult because there are a lot of things to control
(next zone, click anywhere on the page, etc...).

I've tried to understand a bit more the W3C DOM and I have some
problems...

If I write an event handler :
document.getElementById("var01").addEventListener( "change",monchange,true);
this is ok and the monchange function is called.
In this function, if I do an alert(event.cancelable), the answer is
true !!!
But then, neither a preventDefault or stopPropagation works...
If the event is keypress or keydown (not keyup nor change), this is ok
!!!

I dont't understand the W3C DOM at all !!!
If the event (change) is cancelable, how can I cancel it ?

David.

Jul 11 '06 #10
"David BERCOT" <da**********@wanadoo.frwrites:
>What you could do was have a check when you leave a field, that sets
stores the erroneous field somewhere, and then, onfocus in the other
controls, see if there is an erroneous control and set focus back.

Hum, it is quite difficult because there are a lot of things to control
(next zone, click anywhere on the page, etc...).
Another solution is to delay the focusing, i.e.,

<input type="text"
onblur="var self=this;setTimeout(function(){self.focus();},1); ">

This should put the focusing at the end of the queue.
If I write an event handler :
document.getElementById("var01").addEventListener( "change",monchange,true);
this is ok and the monchange function is called.
In this function, if I do an alert(event.cancelable), the answer is
true !!!
But then, neither a preventDefault or stopPropagation works...
I'm not sure what it means to cancel a "change" event (which probably
means that it should not be cancelable :). Being cancelable mean that
preventDefault() should cancel the default behavior.
According to the W3C, "change" events in HTML should not be cancelable.
If the event is keypress or keydown (not keyup nor change), this is ok
!!!
There is a default action to prevent in that case.
I dont't understand the W3C DOM at all !!!
It's a jungle :).
If the event (change) is cancelable, how can I cancel it ?
The correct way *is* to use preventDefault. It probably isn't
cancelable, even if your browser erroneously report it as such.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 11 '06 #11

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

Similar topics

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...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
14
by: xxbmichae1 | last post by:
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...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
4
by: David McNerney | last post by:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1 for MacOSX when I type some text and hit Enter in the following form: <html> <body> <form action="http://example.com"...
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
1
by: Stewart | last post by:
Dear All, I discovered last night that IE6 doesn't support the onchange event on the form object. I had written some script in Firefox, and tested in IE, and spent a long time trying to debug...
1
by: Jan Doggen | last post by:
Hello all, I have a SELECT like this (the 'alert()s are temporary): <FORM method="POST" action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:1095144287.9159" id="hulpform"...
1
by: daokfella | last post by:
I need to raise the onchange event and Firefox is giving me some grief. I hear fireEvent is buggy with some events. Is that true? My code is simply this: targetTextbox.fireEvent("onChange"); ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
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:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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
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
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...

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.