Display results in SELECT - Firefox issue

T

Tom de Neef

My document has a scrollable list defined by
<FORM><SELECT ID='results' onClick='SelectItem()'></SELECT></FORM>
The idea is to display results of a search in the list.
The search routine adds <OPTION> elements to the results list. Simplified it
looks like:

outputField = document.getElementById('results')
newElement = document.createElement('OPTION')
newElement.innerText = someName
outputField.appendChild(newElement)

And at completion I add:
outputField.focus()
outputField.selectIndex=0

With IE this works fine. The results are displayed in the list and the first
line is selected.
With FF it does not work. The scrollbar on the results list indicates that
items have been added to the list, but none is displayed. The (empty) top
line gets focus. (The onClick for the SELECT list works and it indicates
that this first line is indeed associated with the first results item.)

I have no idea where to start looking for a solution. What should I do to
display the results in Firefox?
Anybody any ideas? Many thanks in advance.
Tom
 
S

SAM

Tom de Neef a écrit :
My document has a scrollable list defined by
<FORM><SELECT ID='results' onClick='SelectItem()'></SELECT></FORM>
The idea is to display results of a search in the list.
The search routine adds <OPTION> elements to the results list. Simplified it
looks like:

outputField = document.getElementById('results')
newElement = document.createElement('OPTION')
newElement.innerText = someName

newElement.text = someName
outputField.appendChild(newElement)

You can also use our grand ma's JS :

var outputField = document.getElementById('results');
var idx = outputField.length;
// new Option(text, value)
var newElement = new Option(someName+' '+idx, '');
// grow the list and gives the new option
outputField.options[idx] = newElement;
With IE this works fine. The results are displayed in the list and the first
line is selected.
With FF it does not work. The scrollbar on the results list indicates that
items have been added to the list, but none is displayed. The (empty) top
line gets focus. (The onClick for the SELECT list works and it indicates
that this first line is indeed associated with the first results item.)

I have no idea where to start looking for a solution. What should I do to
display the results in Firefox?
Anybody any ideas? Many thanks in advance.

<html>
<script type="text/javascript">
function ajout(someName) {
var outputField = document.getElementById('results');
var idx = outputField.length;
var newElement = new Option(someName+' '+idx, '');
outputField.options[outputField.length] = newElement;
}
</script>
<form>
<select onclick="ajout('test');" id="results">
<option>try me</option>
</select>
</form>
</html>


With my Fx that adds 2 options
(one click to display the list + one click to click)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top