473,387 Members | 1,516 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,387 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 4893
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.