473,763 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = "MySelectio n" 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.MyFor m.MySelection.s electedIndex = 1;
document.MyForm .MySelection.fo cus();">
</form>
</body>
</html>
Nov 27 '05 #1
7 1947
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 programmaticall y
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/HTMLSelectEleme nt.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
11866
by: Jeff Thies | last post by:
Is there a NS7, Opera7 or Mozilla equivalent for: document.selection.createRange(); Jeff
20
12305
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 appears as if Mozilla needs to have the focus set on that div in order for the mousewheel to work. That's all that link does. The mousewheel works perfectly in IE without the link. It scrolls the div even if there is a scrollbar on the page. Is...
8
2018
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 to that button, so there is no text to be selected. What should I do? Below you'll see some code that I have in one of my forms. I was hoping to have these buttons and when I click on them they would take selected text from a textarea box and...
15
3324
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) { var range = document.selection.createRange(); if (range.parentElement() == element) range.text = '<' + tag + '>' + range.text + '<\/' + tag + '>'; }
8
9707
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 doing all in the header first, all in the sidebar second, etc. A base page contains includes for all the pieces and has the body tag. I am trying to use code pasted below. Help would be appreciated. Thanks <script language="javascript"> <!--
64
6422
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 user sees is content in only one language at a time. He or she can then switch to another language and set this as the preferred language, but again he or she sees content in only this one other language. The question now is: How do I get search...
11
5815
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
4299
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: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) #self.fontlist is the
1
4743
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 records at record level and at group level. For example, I may select all bill lines with a receipt date within a certain date range. This results in a list of bill lines within that date range. The records are grouped and values on the records...
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.