473,387 Members | 2,436 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.

Index of selection is wrong after setting a new index within Mozilla

I choose 'Entry 4' and click then on the button 'Set' to set the index to
'Entry 2'. If you press now the cursor down key 'Entry 5' instead of 'Entry
3' shows up with Mozilla Firefox. With Internet Explorer and Opera it works
fine; 'Entry 3' shows up.

Is this a bug within Mozilla Firefox or do I have any possibility to change
this wrong behavior?
Stefan

========================

<html>
<body>
<form name = "MyForm" action = "" method = "post">
<select name = "MySelection" size = "1">
<option value = "1">Entry 1
<option value = "2">Entry 2
<option value = "3">Entry 3
<option value = "4">Entry 4
<option value = "5">Entry 5
<option value = "6">Entry 6
</select>

<input type = "button" value = "Set" onClick =
"document.MyForm.MySelection.selectedIndex = 1;
document.MyForm.MySelection.focus();">
</form>
</body>
</html>
Nov 27 '05 #1
7 1920
Stefan,

I'm afraid I can't offer any solution, but can say that the problem
happens in my Firefox installation as well (1.0.7). I'd see if it's
fixed in the latest version of Firefox and if not submit a bug report
(if hasn't already been submitted).

If you wanted to work-around it, all I can think of is to keep your own
selected state in a variable, capture the key events and over-ride
Firefox's handling of the event - although that seems like more trouble
than its worth.

Cheers,
Matt
--
EditMe - Edit your web.
http://www.editme.com

Nov 28 '05 #2
Stefan Mueller wrote:
I choose 'Entry 4' and click then on the button 'Set' to set the index to
'Entry 2'. If you press now the cursor down key 'Entry 5' instead of 'Entry
3' shows up with Mozilla Firefox. With Internet Explorer and Opera it works
fine; 'Entry 3' shows up.

Is this a bug within Mozilla Firefox or do I have any possibility to change
this wrong behavior?


No, it's not a bug.

The selectedIndex property of a select element is a number, not a
method, though some browsers may allow you to use it as such. To change
the selected option to index 1, use:

document.MyForm.MySelection[1].selected = true;
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...t-binding.html >
and
<URL: http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-85676760 >

[...]

--
Rob
Nov 28 '05 #3
RobG wrote:
Stefan Mueller wrote:
I choose 'Entry 4' and click then on the button 'Set' to set the index to
'Entry 2'. If you press now the cursor down key 'Entry 5' instead of
'Entry 3' shows up with Mozilla Firefox. With Internet Explorer and Opera
it works fine; 'Entry 3' shows up.

Is this a bug within Mozilla Firefox or do I have any possibility to
change this wrong behavior?
No, it's not a bug.


I think it is.
The selectedIndex property of a select element is a number, not a
method, though some browsers may allow you to use it as such.
Pardon? He assigned the index number 1 to that property. However, he
decribes that if the next option is selected manually via the keyboard,
it is as if 'Entry 4' (index number 3) was still selected. That _is_
a bug. It can best be observed when using Alt+Cursor Down first to
expand the list: the selection "jumps" down over two other options.

Same with other previously selected options and Cursor Up key here
in Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922
Firefox/1.0.7 (Debian package 1.0.7-1) Mnenhy/0.7.2.0
To change
the selected option to index 1, use:

document.MyForm.MySelection[1].selected = true;


That works only because it is not a multiple select. selectedIndex is
indeed the read/write property of choice for such elements. You should
read the references you are using :)
PointedEars
Nov 28 '05 #4
> To change the selected option to index 1, use:

document.MyForm.MySelection[1].selected = true;


Also with you suggestion my Mozilla Firefox experiences the same bug.
Stefan
Nov 28 '05 #5
Thomas 'PointedEars' Lahn wrote:
RobG wrote:

Stefan Mueller wrote:
I choose 'Entry 4' and click then on the button 'Set' to set the index to
'Entry 2'. If you press now the cursor down key 'Entry 5' instead of
'Entry 3' shows up with Mozilla Firefox. With Internet Explorer and Opera
it works fine; 'Entry 3' shows up.

Is this a bug within Mozilla Firefox or do I have any possibility to
change this wrong behavior?
No, it's not a bug.


I think it is.
The selectedIndex property of a select element is a number, not a
method, though some browsers may allow you to use it as such.


Pardon? He assigned the index number 1 to that property. However, he
decribes that if the next option is selected manually via the keyboard,
it is as if 'Entry 4' (index number 3) was still selected. That _is_
a bug. It can best be observed when using Alt+Cursor Down first to
expand the list: the selection "jumps" down over two other options.

I went over the whole thing again and I was completely off track, I
missed the point completely. You are exactly right, the arrow keys
don't select the next option, they go to the next option of whatever was
previously selected. You can change the selectedIndex programmatically
all you like, the previous UI-selected option is used for the next
keyboard-initiated selection.

And my 'fix' doesn't change that - yes, I'd call it a bug.
[...]
indeed the read/write property of choice for such elements. You should
read the references you are using :)
That is a good point - what are the references?

Let me go off-topic here a bit. The DOM 2 spec just says it's a number
and only mentions returned values - should I infer that any property
that isn't read only can be set? Where does it tell me what will happen
if I set the value to something?

The Mozilla Gecko DOM reference doesn't mention it - the form interface
stuff just talks about the form element.

The Netscape DevEdge stuff from 2000 on the Mozilla site which says what
you describe - the selectedIndex property should be used to set the
selected index property for single selects and for multiple selects
where previous selections should be cleared at the same time.
Apparently it was introduced in JavaScript 1.0.

<URL:
http://devedge-temp.mozilla.org/libr...t.html#1193420


The Microsoft documentation also mentions that it can be set.

--
Rob
Nov 28 '05 #6
vdP
Matt - EditMe.com wrote:
Stefan,

I'm afraid I can't offer any solution, but can say that the problem
happens in my Firefox installation as well (1.0.7). I'd see if it's
fixed in the latest version of Firefox and if not submit a bug report
(if hasn't already been submitted).


It works fine in my FireFox 1.5.

vdP
Nov 28 '05 #7
RobG wrote:
Thomas 'PointedEars' Lahn wrote:
[selectedIndex is] indeed the read/write property of choice for
such elements. You should read the references you are using :)
That is a good point - what are the references?


I meant the section of DOM Level 2 HTML you referred us to :)
Let me go off-topic here a bit. The DOM 2 spec just says it's a number
and only mentions returned values - should I infer that any property
that isn't read only can be set?
Yes.
Where does it tell me what will happen if I set the value to something?
It does not always. It does not in this case.
The Mozilla Gecko DOM reference doesn't mention it - the form interface
stuff just talks about the form element.
The Gecko DOM Reference is not quite complete. You can refer to
XULPlanet for all missing documentation:

<URL:http://xulplanet.com/references/objref/HTMLSelectElement.html>

<URL:http://mozref.com/> also once provided information about element
host objects, however no longer.
The Netscape DevEdge stuff from 2000 on the Mozilla site which says what
you describe - the selectedIndex property should be used to set the
selected index property for single selects and for multiple selects
where previous selections should be cleared at the same time.
Apparently it was introduced in JavaScript 1.0. [...]


Exactly. Before JavaScript 1.4, host objects were language features.
PointedEars
Nov 28 '05 #8

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

Similar topics

1
by: Jeff Thies | last post by:
Is there a NS7, Opera7 or Mozilla equivalent for: document.selection.createRange(); Jeff
20
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It...
8
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts...
15
by: lawrence | last post by:
Is this the correct way to test for a method before I use it? createRange() is, I believe, an IE only method. function wrapSelectionInTag(selection, tag) { if (document.selection.createRange)...
8
by: David McDivitt | last post by:
I need to set tabs on java generated pages. Pages have four sections: header, sidebar, body, and footer. The sidebar and body change dynamically. The tab key must go to anchors, fields, and buttons...
64
by: Manfred Kooistra | last post by:
I am building a website with identical content in four different languages. On a first visit, the search engine determines the language of the content by the IP address of the visitor. What the...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
1
by: annemariearmour | last post by:
I am using Crystal reports version 11.2 to create reports. The data source is SQL Server, and I am using views rather than reporting directly from tables. I apply selection criteria to the incoming...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.