This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SELECT boxes in Netscape

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
We are having a problem with Select boxes in Netscape 4.76
All of our selection boxes have an 'ALL' option and then various other options following.
There is a bit of javascript so that when a user selects non 'ALL' option, then 'ALL' is deselected, and when 'ALL' is selected by the user, all of the other options are deselected.
The problem is that if the 'ALL' option is selected, and a user picks an option from way down the list (past the first 'page'), the select box is scrolled back to the top of the list.
We want the list to stay 'unscrolled' so that the user can continue to make further selections without having to scroll back down the list again.
Some sample code is show below ...
Thanks in advance for any help.
Andrew.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code should work:
function selectDeselectAllQuarters(){
// set listbox to the select item of the form
var listbox = document.report_form.quarter;

// get the index of the selected option
var selectedOption = listbox.selectedIndex;

// if the selected option is the first one (which value is "ALL")
if (selectedOption == 0){
// unselect all others options
listbox.selectedIndex = 0;
}
}
However, if the first option is selected and you try to select another question by holding down a control key like Ctrl or Shift, only the first option remains selected (which seems to be logical).
 
Andrew Wilcockson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Xavier,
Thanks for the suggestion.
You may not have noticed the 'multiple' option in the select tag.
The users need to be able to select one or more options from the selection box.
The problem only occurs when they make the first selection and the currently selected option is 'ALL'.
Once they have selected the first non 'ALL' option, any further selections do not result in the selection box scrolling back to the top.
I am fairly certain that it is the line
document.report_form.quarter.options[0].selected = false;
that is causing the problem, but I cannot see any other way to do what we want to do.
Anyone got any more suggestions ?
Thanks,
Andrew.

[This message has been edited by Andrew Wilcockson (edited August 22, 2001).]
 
xavier romea
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with netscape is when you set the selected property of any option, netscape refreshes the display of the select box, which scrolls back to the top. The solution is ot not set this property of any option.
I tried my code and it works... (for information, i tried it on netscape 4.7)
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic