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

SELECT Onchange 'delayed' in Firefox on keypress?

Hello all,

I have a SELECT like this (the 'alert()s are temporary):
<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.9159"
id="hulpform" name="hulpform">
<select name="varVervuld" id="varVervuld"
onChange="alert('Onchange');Vervuld(this.options[this.selectedIndex]);">
<option value="0" selected="selected">&nbsp;</option>
<option value=JA>Ja</option>
<option value=NEE>Nee</option>
</select>
</FORM>

with procedure VerVuld() rewriting the contents of a DIV with a second FORM
(see below):

function Vervuld(optie)
{
var x = optie.value;
var BL = document.getElementById('bottomlayer');
alert('Vervuld('+x+')');
if (x == 'JA')
{
BL.innerHTML = '<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.4331"
id="form1" name="form1">'
+ 'Op welke wijze is de vacature vervuld? Kies één van de volgende
mogelijkheden:'
+ '<UL><LI>www.onderwijsvacaturebank.nl</LI><LI>Intermediaire organisatie
(bv. CWI/Uitzendbureau)</LI><LI>www.werk.nl of andere vacaturebank op
internet</LI><LI>Advertentie in krant</LI><LI>Open
sollicitatie</LI><LI>Intern</LI><LI>Via eigen netwerk/persoonlijke
contacten</LI><LI>Anders, nl</LI></UL>'
+ '<table><tr><td><strong>Vervuld via</strong></td><td>'
+ '<select size="1" name="litVervuld" id="litVervuld">'
+ '<OPTION VALUE="0" SELECTED>&nbsp;<OPTION
VALUE="1">www.onderwijsvacaturebank.nl<OPTION VALUE="4">Intermediaire
organisatie (bv. CWI/Uitzendbureau)<OPTION VALUE="6">www.werk.nl of andere
vacaturebank op internet<OPTION VALUE="2">Advertentie in krant<OPTION
VALUE="7">Open sollicitatie<OPTION VALUE="3">Intern<OPTION VALUE="8">Via
eigen netwerk/persoonlijke contacten<OPTION VALUE="5">Anders, nl</select*'
+ '</td></tr><tr><td valign=top><strong>Ruimte voor
toelichting</strong></td><td><textarea name="txtVervuldToelichting" rows="4"
cols="40"></textarea></td></tr></table>'
+ '<br />Door wie is de vacature vervuld? Kies één van de volgende
mogelijkheden:'
+ '<UL><LI>Werkzaam binnen onderwijs</LI><LI>Werkzaam buiten
onderwijs</LI><LI>Pas
afgestudeerde</LI><LI>Wachtgelder</LI><LI>Herintreder</LI><LI>Werkloze (niet
zijnde wachtgelder)</LI><LI>Anders</LI></UL>'
+ '<table><tr><td><strong>Vervuld door</strong></td><td>'
+ '<select size="1" name="litPersonage" id="litPersonage">'
+ '<OPTION VALUE="0" SELECTED>&nbsp;<OPTION VALUE="8">Werkzaam binnen
onderwijs<OPTION VALUE="9">Werkzaam buiten onderwijs<OPTION VALUE="10">Pas
afgestudeerde<OPTION VALUE="11">Wachtgelder<OPTION
VALUE="12">Herintreder<OPTION VALUE="13">Werkloze (niet zijnde
wachtgelder)<OPTION VALUE="15">Anders</select*'
+ '</td></tr><tr><td valign=top><strong>Ruimte voor
toelichting</strong></td><td>'
+ '<textarea name="txtVervuldDoorToelichting"
id="txtVervuldDoorToelichting" rows="4"
cols="40"></textarea></td></tr></table>'
+ '<input type="hidden" id="selKeuze" name="selKeuze" value=' + x + '><p>*
= dit is een verplicht in te vullen veld</p></FORM>';
}
else if (x == 'NEE')
{
BL.innerHTML = '<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.9653"
id="form1" name="form1">'
+ 'Waarom is de vacature niet vervuld?<br />Kies één van de volgende
mogelijkheden:'
+ '<UL><LI>Vacature is vervallen</LI><LI>Foutieve opvoer of wijziging in
vacaturegegevens</LI><LI>Anders, nl</LI></UL>'
+ '<table><tr><td><strong>Niet vervuld</strong></td><td>'
+ '<select size="1" name="litNietVervuld" id="litNietVervuld">'
+ '<OPTION VALUE="0" SELECTED>&nbsp;<OPTION VALUE="1">Vacature is
vervallen<OPTION VALUE="3">Foutieve opvoer of wijziging in
vacaturegegevens<OPTION VALUE="2">Anders, nl</select*'
+ '</td></tr><tr><td valign=top><strong>Ruimte voor
toelichting</strong></td><td>'
+ '<textarea name="txtNietVervuldToelichting"
id="txtNietVervuldToelichting" rows="4"
cols="40"></textarea></td></tr></table>'
+ '<input type="hidden" id="selKeuze" name="selKeuze" value=' + x + '><p>*
= dit is een verplicht in te vullen veld</p></FORM>';
}
else
{
BL.innerHTML = '<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.1025"
id="form1" name="form1"><input type="hidden" id=selKeuze name=selKeuze
value=' + x + '></FORM>';
}
alert('Vervuld ends');
return true;
}

This is the DIV that gets rewritten:

<div id="bottomlayer" name="bottomlayer">
<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.6068"
id="form1" name="form1">
<input type="hidden" id="selKeuze" name="selKeuze">
</FORM>
</div>

Everything works fine when I use the mouse for selecting values in the
varVervuld SELECT.
However, when I press J or N, Vervuld() does *not* get called (the alert in
the onchange doesn't even fire).
The contents of VarVervuld change from Ja to Nee 2 or 3 times, then it seems
'stuck' (and DIV bottomlayer never gets updated).
If I then e.g. tab away from VarVervuld or alt-tab away to another Windows
app, the OnChange gets triggered and the screen updates.
In IE it all works as expected.

I tried e.g. explicitly setting focus back to varVervuld right before the
return true:
var Elem=document.getElementById("varVervuld");
setTimeout("Elem.focus();",0);
but that makes no difference.

Any ideas?
TIA
Jan


Sep 8 '06 #1
1 4999

Jan Doggen wrote:
Hello all,

I have a SELECT like this (the 'alert()s are temporary):
<FORM method="POST"
action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:10951442 87.9159"
id="hulpform" name="hulpform">
<select name="varVervuld" id="varVervuld"
onChange="alert('Onchange');Vervuld(this.options[this.selectedIndex]);">
<option value="0" selected="selected">&nbsp;</option>
<option value=JA>Ja</option>
<option value=NEE>Nee</option>
</select>
</FORM>
[...]

Do not allow posted code to auto-wrap, I couldn't be bothered to remove
all the errors caused by it. Manually wrap it at about 70 characters.

The best idea is to post a minimal example that demonstrates the issue
and that works when copied to an empty page.

Everything works fine when I use the mouse for selecting values in the
varVervuld SELECT.
However, when I press J or N, Vervuld() does *not* get called (the alert in
the onchange doesn't even fire).
The contents of VarVervuld change from Ja to Nee 2 or 3 times, then it seems
'stuck' (and DIV bottomlayer never gets updated).
If I then e.g. tab away from VarVervuld or alt-tab away to another Windows
app, the OnChange gets triggered and the screen updates.
In IE it all works as expected.
[...]
Any ideas?
The onchange event pretty much epitomises the issue of inconsistent
implementation of standards by browsers. In this case, Firefox is
"correct" according to the specification in that it fires when the
control loses focus, IE fires the event too early. With radio buttons,
the situtation is reversed. Your opinion on which is the more
desirable behaviour (as opposed to the more correct) depends on what
you are trying to do when you discover the inconsistency.

The only help I can offer at this stage is to fire the handler from
some other event, or combination of events.
--
Rob

Sep 8 '06 #2

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...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
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...
1
by: kebabkongen | last post by:
Hi, I'm working on a JavaScript that is enabling / disabling a select element according to whether a checkbox is selected or not. This works fine in Firefox, but in Internet Explorer (v 6.0.2900)...
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"...
16
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on...
1
by: bambr | last post by:
I'm using following code: function cloneRow(tBodyId, sourceRowId) { var obj = document.getElementById(tBodyId); if(obj.tagName != 'TBODY') { for(var i = 0; i < obj.childNodes.length;...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
13
by: andypb123 | last post by:
Hello, The onchange event fires in IE6 in a SELECT element when scrolling through the list with the up and down arrows on the keyboard. In Firefox it only fires after you hit the enter key, which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.